UNPKG

@syntest/core

Version:

The common core of the SynTest Framework

81 lines 2.61 kB
"use strict"; /* * Copyright 2020-2021 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.StatisticsCollector = void 0; /** * Collector for runtime statistics. * * @author Mitchell Olsthoorn */ class StatisticsCollector { /** * Constructor. * * @param timeBudget The time budget to use for tracking time */ constructor(timeBudget) { this._timeBudget = timeBudget; this._variables = new Map(); this._eventVariables = new Map(); } /** * Record a static variable in the collector. * * @param variable The variable type to record * @param value The variable value */ recordVariable(variable, value) { this._variables.set(variable, value); return this; } /** * Record a dynamic variable in the collector. * * The event is recorded at the current time of the search process. * * @param variable The variable type to record * @param value The variable value */ recordEventVariable(variable, value) { // 1/10th second accuracy const eventTime = Math.round(this._timeBudget.getUsedBudget() * 10) / 10; // If other events already exist on this event time add it, otherwise create a new one if (this._eventVariables.has(eventTime)) { this._eventVariables.get(eventTime).set(variable, `${value}`); } else { this._eventVariables.set(eventTime, new Map().set(variable, `${value}`)); } return this; } /** * Return the static variables stored in the collector */ getVariables() { return this._variables; } /** * Return the dynamic variables stored in the collector */ getEventVariables() { return this._eventVariables; } } exports.StatisticsCollector = StatisticsCollector; //# sourceMappingURL=StatisticsCollector.js.map