Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@syntest/metric

Package Overview
Dependencies
Maintainers
4
Versions
20
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@syntest/metric - npm Package Compare versions

Comparing version 0.1.0-beta.8 to 0.1.0-beta.9

1

dist/index.d.ts

@@ -6,3 +6,2 @@ export * from "./lib/Middleware";

export * from "./lib/MetricManager";
export * from "./lib/PropertyTypes";
//# sourceMappingURL=index.d.ts.map

@@ -39,3 +39,2 @@ "use strict";

__exportStar(require("./lib/MetricManager"), exports);
__exportStar(require("./lib/PropertyTypes"), exports);
//# sourceMappingURL=index.js.map

28

dist/lib/Metric.d.ts

@@ -1,19 +0,18 @@

import { SeriesUnit } from "./PropertyTypes";
export type Metric = PropertyMetric | DistributionMetric | SeriesMetric | SeriesDistributionMetric | SeriesMeasurementMetric;
export interface PropertyMetric {
type: MetricType.PROPERTY;
name: string;
name: MetricName;
}
export interface DistributionMetric {
type: MetricType.DISTRIBUTION;
name: string;
name: MetricName;
}
export interface SeriesMetric {
type: MetricType.SERIES;
name: string;
name: MetricName;
seriesUnit: SeriesUnit;
}
export interface SeriesDistributionMetric {
type: MetricType.SERIES_DISTRUBUTION;
name: string;
type: MetricType.SERIES_DISTRIBUTION;
name: MetricName;
seriesUnit: SeriesUnit;

@@ -23,5 +22,9 @@ }

type: MetricType.SERIES_MEASUREMENT;
name: string;
name: MetricName;
seriesUnit: SeriesUnit;
}
export type PropertiesMap<T> = Map<MetricName, T>;
export type DistributionsMap = Map<MetricName, Distribution>;
export type SeriesMap<T> = Map<MetricName, Map<SeriesUnit, Series<T>>>;
export type MetricName = string;
export declare enum MetricType {

@@ -31,5 +34,14 @@ PROPERTY = "property",

SERIES = "series",
SERIES_DISTRUBUTION = "series-distribution",
SERIES_DISTRIBUTION = "series-distribution",
SERIES_MEASUREMENT = "series-measurement"
}
export type Distribution = number[];
export declare enum SeriesUnit {
SEARCH_TIME = "search-time",
TOTAL_TIME = "total-time",
EVALUATION = "evaluation",
ITERATION = "iteration"
}
export type Series<T> = Map<SeriesIndex, T>;
export type SeriesIndex = number;
//# sourceMappingURL=Metric.d.ts.map
"use strict";
/*
* Copyright 2020-2023 Delft University of Technology and SynTest contributors
*
* This file is part of SynTest Framework - SynTest Core.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.MetricType = void 0;
exports.SeriesUnit = exports.MetricType = void 0;
var MetricType;

@@ -9,5 +26,12 @@ (function (MetricType) {

MetricType["SERIES"] = "series";
MetricType["SERIES_DISTRUBUTION"] = "series-distribution";
MetricType["SERIES_DISTRIBUTION"] = "series-distribution";
MetricType["SERIES_MEASUREMENT"] = "series-measurement";
})(MetricType = exports.MetricType || (exports.MetricType = {}));
var SeriesUnit;
(function (SeriesUnit) {
SeriesUnit["SEARCH_TIME"] = "search-time";
SeriesUnit["TOTAL_TIME"] = "total-time";
SeriesUnit["EVALUATION"] = "evaluation";
SeriesUnit["ITERATION"] = "iteration";
})(SeriesUnit = exports.SeriesUnit || (exports.SeriesUnit = {}));
//# sourceMappingURL=Metric.js.map
import { Logger } from "@syntest/logging";
import { DistributionMetric, Metric, PropertyMetric, SeriesDistributionMetric, SeriesMeasurementMetric, SeriesMetric } from "./Metric";
import { MiddleWare } from "./Middleware";
import { Distribution, DistributionsMap, Name, PropertiesMap, Series, SeriesMap, SeriesUnit } from "./PropertyTypes";
import { Distribution, DistributionMetric, DistributionsMap, Metric, MetricName, PropertiesMap, PropertyMetric, Series, SeriesDistributionMetric, SeriesIndex, SeriesMap, SeriesMeasurementMetric, SeriesMetric, SeriesUnit } from "./Metric";
import { Middleware } from "./Middleware";
export declare class MetricManager {

@@ -16,3 +15,3 @@ protected static LOGGER: Logger;

private seriesDistributions;
private seriesMeasurement;
private seriesMeasurements;
constructor(namespace: string);

@@ -27,13 +26,13 @@ get outputMetrics(): Metric[];

get namespace(): string;
runPipeline(middleware: MiddleWare[]): Promise<void>;
recordProperty(property: Name, value: string): void;
recordDistribution(distributionName: Name, value: number): void;
recordSeries(seriesName: Name, seriesUnit: SeriesUnit, index: number, value: number): void;
recordSeriesDistribution(name: Name, seriesUnit: SeriesUnit, index: number, value: number): void;
recordSeriesMeasurement(name: Name, seriesUnit: SeriesUnit, index: number, key: string, value: number): void;
getProperty(property: string): string | undefined;
getDistribution(distributionName: string): number[] | undefined;
getSeries(seriesName: string, seriesUnit: SeriesUnit): Map<number, number> | undefined;
getSeriesDistribution(name: string, seriesUnit: SeriesUnit): Map<number, number[]> | undefined;
getSeriesMeasurement(name: string, seriesUnit: SeriesUnit): Series<PropertiesMap<number>> | undefined;
runPipeline(middleware: Middleware[]): Promise<void>;
recordProperty(property: MetricName, value: string): void;
recordDistribution(distributionName: MetricName, value: number): void;
recordSeries(seriesName: MetricName, seriesUnit: SeriesUnit, seriesIndex: SeriesIndex, value: number): void;
recordSeriesDistribution(seriesDistributionName: MetricName, seriesUnit: SeriesUnit, seriesIndex: SeriesIndex, value: number): void;
recordSeriesMeasurement(seriesMeasurementName: MetricName, seriesUnit: SeriesUnit, seriesIndex: SeriesIndex, key: string, value: number): void;
getProperty(property: MetricName): string | undefined;
getDistribution(distributionName: MetricName): Distribution | undefined;
getSeries(seriesName: MetricName, seriesUnit: SeriesUnit): Map<SeriesIndex, number> | undefined;
getSeriesDistribution(seriesDistributionName: MetricName, seriesUnit: SeriesUnit): Map<SeriesIndex, number[]> | undefined;
getSeriesMeasurement(seriesMeasurementName: string, seriesUnit: SeriesUnit): Series<PropertiesMap<number>> | undefined;
getAllProperties(): PropertiesMap<string>;

@@ -44,3 +43,3 @@ getAllDistributions(): DistributionsMap;

getAllSeriesMeasurements(): SeriesMap<PropertiesMap<number>>;
collectProperties(wanted: PropertyMetric[]): Map<string, string>;
collectProperties(wanted: PropertyMetric[]): PropertiesMap<string>;
collectDistributions(wanted: DistributionMetric[]): DistributionsMap;

@@ -47,0 +46,0 @@ collectSeries(wanted: SeriesMetric[]): SeriesMap<number>;

@@ -46,3 +46,3 @@ "use strict";

this.seriesDistributions = new Map();
this.seriesMeasurement = new Map();
this.seriesMeasurements = new Map();
}

@@ -55,2 +55,3 @@ get outputMetrics() {

}
// eslint-disable-next-line sonarjs/cognitive-complexity
merge(other) {

@@ -70,24 +71,36 @@ // Merge properties

// Merge series
for (const [name, seriesData] of other.series.entries()) {
const seriesMap = new Map();
for (const [type, seriesTypeData] of seriesData.entries()) {
seriesMap.set(type, new Map(seriesTypeData));
for (const [name, seriesByType] of other.series.entries()) {
const seriesMetricMap = new Map();
for (const [unit, series] of seriesByType.entries()) {
seriesMetricMap.set(unit, new Map(series));
}
this.series.set(name, seriesMap);
this.series.set(name, seriesMetricMap);
}
// Merge series distributions
for (const [name, seriesDistributionData,] of other.seriesDistributions.entries()) {
const seriesMap = new Map();
for (const [seriesUnit, seriesTypeData,] of seriesDistributionData.entries()) {
seriesMap.set(seriesUnit, new Map(seriesTypeData));
for (const [name, seriesDistributionsByType,] of other.seriesDistributions.entries()) {
const seriesDistributionsMetricMap = new Map();
for (const [unit, series] of seriesDistributionsByType.entries()) {
const seriesDistributionsMap = new Map();
for (const [seriesIndex, distribution] of series.entries()) {
seriesDistributionsMap.set(seriesIndex, [...distribution]);
}
seriesDistributionsMetricMap.set(unit, seriesDistributionsMap);
}
this.seriesDistributions.set(name, seriesMap);
this.seriesDistributions.set(name, seriesDistributionsMetricMap);
}
// Merge series measurements
for (const [name, seriesMeasurementData,] of other.seriesMeasurement.entries()) {
const seriesMap = new Map();
for (const [seriesUnit, seriesTypeData,] of seriesMeasurementData.entries()) {
seriesMap.set(seriesUnit, new Map(seriesTypeData));
for (const [name, seriesMeasurementsByType,] of other.seriesMeasurements.entries()) {
const seriesMeasurementsMetricMap = new Map();
for (const [unit, series] of seriesMeasurementsByType.entries()) {
const seriesMeasurementsMap = new Map();
for (const [seriesIndex, measurements] of series.entries()) {
const measurementsMap = new Map();
for (const [key, value] of measurements.entries()) {
measurementsMap.set(key, value);
}
seriesMeasurementsMap.set(seriesIndex, measurementsMap);
}
seriesMeasurementsMetricMap.set(unit, seriesMeasurementsMap);
}
this.seriesMeasurement.set(name, seriesMap);
this.seriesMeasurements.set(name, seriesMeasurementsMetricMap);
}

@@ -120,5 +133,3 @@ }

switch (m.type) {
case "property": {
return split[1] === "*" || m.name === split[1];
}
case "property":
case "distribution": {

@@ -182,6 +193,6 @@ return split[1] === "*" || m.name === split[1];

case "series-measurement": {
if (!this.seriesMeasurement.has(metric.name)) {
this.seriesMeasurement.set(metric.name, new Map());
if (!this.seriesMeasurements.has(metric.name)) {
this.seriesMeasurements.set(metric.name, new Map());
}
this.seriesMeasurement
this.seriesMeasurements
.get(metric.name)

@@ -223,4 +234,4 @@ .set(metric.seriesUnit, new Map());

}
recordSeries(seriesName, seriesUnit, index, value) {
MetricManager.LOGGER.debug(`Recording series ${seriesName}.${seriesUnit}[${index}] = ${value}`);
recordSeries(seriesName, seriesUnit, seriesIndex, value) {
MetricManager.LOGGER.debug(`Recording series ${seriesName}.${seriesUnit}[${seriesIndex}] = ${value}`);
if (!this.series.has(seriesName)) {

@@ -230,31 +241,51 @@ throw new Error((0, diagnostics_1.seriesNotRegistered)(seriesName));

if (!this.series.get(seriesName).has(seriesUnit)) {
throw new Error((0, diagnostics_1.seriesTypeNotRegistered)(seriesName, seriesUnit));
throw new Error((0, diagnostics_1.seriesUnitNotRegistered)(seriesName, seriesUnit));
}
this.series.get(seriesName).get(seriesUnit).set(index, value);
this.series.get(seriesName).get(seriesUnit).set(seriesIndex, value);
}
recordSeriesDistribution(name, seriesUnit, index, value) {
MetricManager.LOGGER.debug(`Recording series distribution ${name}.${seriesUnit}[${index}] = ${value}`);
if (!this.seriesDistributions.has(name)) {
throw new Error((0, diagnostics_1.seriesDistributionNotRegistered)(name));
recordSeriesDistribution(seriesDistributionName, seriesUnit, seriesIndex, value) {
MetricManager.LOGGER.debug(`Recording series distribution ${seriesDistributionName}.${seriesUnit}[${seriesIndex}] = ${value}`);
if (!this.seriesDistributions.has(seriesDistributionName)) {
throw new Error((0, diagnostics_1.seriesDistributionNotRegistered)(seriesDistributionName));
}
if (!this.seriesDistributions.get(name).has(seriesUnit)) {
throw new Error((0, diagnostics_1.seriesDistributionTypeNotRegistered)(name, seriesUnit));
if (!this.seriesDistributions.get(seriesDistributionName).has(seriesUnit)) {
throw new Error((0, diagnostics_1.seriesDistributionTypeNotRegistered)(seriesDistributionName, seriesUnit));
}
if (!this.seriesDistributions.get(name).get(seriesUnit).has(index)) {
this.seriesDistributions.get(name).get(seriesUnit).set(index, []);
if (!this.seriesDistributions
.get(seriesDistributionName)
.get(seriesUnit)
.has(seriesIndex)) {
this.seriesDistributions
.get(seriesDistributionName)
.get(seriesUnit)
.set(seriesIndex, []);
}
this.seriesDistributions.get(name).get(seriesUnit).get(index).push(value);
this.seriesDistributions
.get(seriesDistributionName)
.get(seriesUnit)
.get(seriesIndex)
.push(value);
}
recordSeriesMeasurement(name, seriesUnit, index, key, value) {
MetricManager.LOGGER.debug(`Recording series measurement ${name}.${seriesUnit}[${index}].${key} = ${value}`);
if (!this.seriesMeasurement.has(name)) {
throw new Error((0, diagnostics_1.seriesDistributionNotRegistered)(name));
recordSeriesMeasurement(seriesMeasurementName, seriesUnit, seriesIndex, key, value) {
MetricManager.LOGGER.debug(`Recording series measurement ${seriesMeasurementName}.${seriesUnit}[${seriesIndex}].${key} = ${value}`);
if (!this.seriesMeasurements.has(seriesMeasurementName)) {
throw new Error((0, diagnostics_1.seriesDistributionNotRegistered)(seriesMeasurementName));
}
if (!this.seriesMeasurement.get(name).has(seriesUnit)) {
throw new Error((0, diagnostics_1.seriesDistributionTypeNotRegistered)(name, seriesUnit));
if (!this.seriesMeasurements.get(seriesMeasurementName).has(seriesUnit)) {
throw new Error((0, diagnostics_1.seriesDistributionTypeNotRegistered)(seriesMeasurementName, seriesUnit));
}
if (!this.seriesMeasurement.get(name).get(seriesUnit).has(index)) {
this.seriesMeasurement.get(name).get(seriesUnit).set(index, new Map());
if (!this.seriesMeasurements
.get(seriesMeasurementName)
.get(seriesUnit)
.has(seriesIndex)) {
this.seriesMeasurements
.get(seriesMeasurementName)
.get(seriesUnit)
.set(seriesIndex, new Map());
}
this.seriesMeasurement.get(name).get(seriesUnit).get(index).set(key, value);
this.seriesMeasurements
.get(seriesMeasurementName)
.get(seriesUnit)
.get(seriesIndex)
.set(key, value);
}

@@ -276,15 +307,15 @@ getProperty(property) {

}
getSeriesDistribution(name, seriesUnit) {
MetricManager.LOGGER.debug(`Getting series distribution ${name}.${seriesUnit}`);
if (!this.seriesDistributions.has(name)) {
getSeriesDistribution(seriesDistributionName, seriesUnit) {
MetricManager.LOGGER.debug(`Getting series distribution ${seriesDistributionName}.${seriesUnit}`);
if (!this.seriesDistributions.has(seriesDistributionName)) {
return undefined;
}
return this.seriesDistributions.get(name).get(seriesUnit);
return this.seriesDistributions.get(seriesDistributionName).get(seriesUnit);
}
getSeriesMeasurement(name, seriesUnit) {
MetricManager.LOGGER.debug(`Getting series measurement ${name}.${seriesUnit}`);
if (!this.seriesMeasurement.has(name)) {
getSeriesMeasurement(seriesMeasurementName, seriesUnit) {
MetricManager.LOGGER.debug(`Getting series measurement ${seriesMeasurementName}.${seriesUnit}`);
if (!this.seriesMeasurements.has(seriesMeasurementName)) {
return undefined;
}
return this.seriesMeasurement.get(name).get(seriesUnit);
return this.seriesMeasurements.get(seriesMeasurementName).get(seriesUnit);
}

@@ -304,3 +335,3 @@ getAllProperties() {

getAllSeriesMeasurements() {
return this.seriesMeasurement;
return this.seriesMeasurements;
}

@@ -307,0 +338,0 @@ collectProperties(wanted) {

import { Metric } from "./Metric";
import { MetricManager } from "./MetricManager";
export declare abstract class MiddleWare {
export declare abstract class Middleware {
protected metricManager: MetricManager;

@@ -5,0 +5,0 @@ protected availableMetrics: Metric[];

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.MiddleWare = void 0;
class MiddleWare {
exports.Middleware = void 0;
class Middleware {
constructor(metricManager, availableMetrics) {

@@ -11,3 +11,3 @@ this.metricManager = metricManager;

}
exports.MiddleWare = MiddleWare;
exports.Middleware = Middleware;
//# sourceMappingURL=Middleware.js.map

@@ -7,6 +7,6 @@ /**

export declare const seriesNotRegistered: (series: string) => string;
export declare const seriesTypeNotRegistered: (seriesName: string, seriesType: string) => string;
export declare const seriesDistributionNotRegistered: (name: string) => string;
export declare const seriesDistributionTypeNotRegistered: (name: string, seriesType: string) => string;
export declare const seriesUnitNotRegistered: (seriesName: string, seriesUnit: string) => string;
export declare const seriesDistributionNotRegistered: (distribution: string) => string;
export declare const seriesDistributionTypeNotRegistered: (distribution: string, seriesUnit: string) => string;
export declare const shouldNeverHappen: (bugLocation: string) => string;
//# sourceMappingURL=diagnostics.d.ts.map

@@ -20,3 +20,3 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.shouldNeverHappen = exports.seriesDistributionTypeNotRegistered = exports.seriesDistributionNotRegistered = exports.seriesTypeNotRegistered = exports.seriesNotRegistered = exports.distributionNotRegistered = exports.propertyNotRegistered = void 0;
exports.shouldNeverHappen = exports.seriesDistributionTypeNotRegistered = exports.seriesDistributionNotRegistered = exports.seriesUnitNotRegistered = exports.seriesNotRegistered = exports.distributionNotRegistered = exports.propertyNotRegistered = void 0;
/**

@@ -31,7 +31,7 @@ * This file is meant to provide consistent error messages throughout the tool.

exports.seriesNotRegistered = seriesNotRegistered;
const seriesTypeNotRegistered = (seriesName, seriesType) => `Cannot record series! Metric '${seriesName}.${seriesType}' is not registered by any module!`;
exports.seriesTypeNotRegistered = seriesTypeNotRegistered;
const seriesDistributionNotRegistered = (name) => `Cannot record series distribution! Metric '${name}' is not registered by any module!`;
const seriesUnitNotRegistered = (seriesName, seriesUnit) => `Cannot record series! Metric '${seriesName}.${seriesUnit}' is not registered by any module!`;
exports.seriesUnitNotRegistered = seriesUnitNotRegistered;
const seriesDistributionNotRegistered = (distribution) => `Cannot record series distribution! Metric '${distribution}' is not registered by any module!`;
exports.seriesDistributionNotRegistered = seriesDistributionNotRegistered;
const seriesDistributionTypeNotRegistered = (name, seriesType) => `Cannot record series distribution! Metric '${name}.${seriesType}' is not registered by any module!`;
const seriesDistributionTypeNotRegistered = (distribution, seriesUnit) => `Cannot record series distribution! Metric '${distribution}.${seriesUnit}' is not registered by any module!`;
exports.seriesDistributionTypeNotRegistered = seriesDistributionTypeNotRegistered;

@@ -38,0 +38,0 @@ const shouldNeverHappen = (bugLocation) => `This should never happen.\nThere is likely a bug in the ${bugLocation}.`;

{
"name": "@syntest/metric",
"version": "0.1.0-beta.8",
"version": "0.1.0-beta.9",
"description": "The metrics library of the SynTest Framework",

@@ -54,3 +54,3 @@ "keywords": [

},
"gitHead": "117e58756aba3fe6a203fccc2f0d0b78826681a8"
"gitHead": "d44097b870745a6cd49cc4c6fa05a962569b7243"
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc