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

@callstack/reassure-measure

Package Overview
Dependencies
Maintainers
10
Versions
23
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@callstack/reassure-measure - npm Package Compare versions

Comparing version 0.6.0 to 1.0.0-beta

lib/commonjs/measure-renders.js

4

lib/commonjs/config.js

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

exports.configure = configure;
exports.resetToDefault = resetToDefault;
exports.resetToDefaults = resetToDefaults;
const defaultConfig = {

@@ -23,5 +23,5 @@ runs: 10,

}
function resetToDefault() {
function resetToDefaults() {
exports.config = config = defaultConfig;
}
//# sourceMappingURL=config.js.map

@@ -21,14 +21,20 @@ "use strict";

get: function () {
return _measureRender.measurePerformance;
return _measureRenders.measurePerformance;
}
});
Object.defineProperty(exports, "resetToDefault", {
Object.defineProperty(exports, "measureRenders", {
enumerable: true,
get: function () {
return _config.resetToDefault;
return _measureRenders.measureRenders;
}
});
Object.defineProperty(exports, "resetToDefaults", {
enumerable: true,
get: function () {
return _config.resetToDefaults;
}
});
var _config = require("./config");
var _measureRender = require("./measure-render");
var _measureRenders = require("./measure-renders");
var _measureFunction = require("./measure-function");
//# sourceMappingURL=index.js.map

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

exports.measureFunction = measureFunction;
exports.measureFunctionInternal = measureFunctionInternal;
var _perf_hooks = require("perf_hooks");

@@ -15,3 +14,5 @@ var _config = require("./config");

const stats = await measureFunctionInternal(fn, options);
await (0, _output.writeTestStats)(stats, 'function');
if ((options === null || options === void 0 ? void 0 : options.writeFile) !== false) {
await (0, _output.writeTestStats)(stats, 'function');
}
return stats;

@@ -22,3 +23,3 @@ }

const warmupRuns = (options === null || options === void 0 ? void 0 : options.warmupRuns) ?? _config.config.warmupRuns;
(0, _output.showFlagsOuputIfNeeded)();
(0, _output.showFlagsOutputIfNeeded)();
const runResults = [];

@@ -25,0 +26,0 @@ for (let i = 0; i < runs + warmupRuns; i += 1) {

@@ -8,11 +8,10 @@ "use strict";

exports.resetHasShownFlagsOutput = resetHasShownFlagsOutput;
exports.showFlagsOuputIfNeeded = showFlagsOuputIfNeeded;
exports.showFlagsOutputIfNeeded = showFlagsOutputIfNeeded;
exports.writeTestStats = writeTestStats;
var fs = _interopRequireWildcard(require("fs/promises"));
var _reassureLogger = require("@callstack/reassure-logger");
var logger = _interopRequireWildcard(require("@callstack/reassure-logger"));
var _config = require("./config");
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
async function writeTestStats(stats, type) {
let outputFilePath = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : _config.config.outputFile;
async function writeTestStats(stats, type, outputFilePath = _config.config.outputFile) {
const name = expect.getState().currentTestName;

@@ -27,16 +26,15 @@ const line = JSON.stringify({

} catch (error) {
_reassureLogger.logger.error(`Error writing ${outputFilePath}`, error);
logger.error(`Error writing ${outputFilePath}`, error);
throw error;
}
}
async function clearTestStats() {
let outputFilePath = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : _config.config.outputFile;
async function clearTestStats(outputFilePath = _config.config.outputFile) {
try {
await fs.unlink(outputFilePath);
} catch (error) {
_reassureLogger.logger.warn(`Cannot remove ${outputFilePath}. File doesn't exist or cannot be removed`);
logger.warn(`Cannot remove ${outputFilePath}. File doesn't exist or cannot be removed`);
}
}
let hasShownFlagsOutput = false;
function showFlagsOuputIfNeeded() {
function showFlagsOutputIfNeeded() {
if (hasShownFlagsOutput) {

@@ -46,5 +44,5 @@ return;

if (!global.gc) {
_reassureLogger.logger.error('❌ Measure code is running under incorrect Node.js configuration.\n' + 'Performance test code should be run in Jest with certain Node.js flags to increase measurements stability.\n' + 'Make sure you use the Reassure CLI and run it using "reassure" command.');
logger.error('❌ Measure code is running under incorrect Node.js configuration.\n' + 'Performance test code should be run in Jest with certain Node.js flags to increase measurements stability.\n' + 'Make sure you use the Reassure CLI and run it using "reassure" command.');
} else {
_reassureLogger.logger.verbose('Measure code is running with correct Node.js configuration.');
logger.verbose('Measure code is running with correct Node.js configuration.');
}

@@ -51,0 +49,0 @@ hasShownFlagsOutput = true;

@@ -14,5 +14,5 @@ const defaultConfig = {

}
export function resetToDefault() {
export function resetToDefaults() {
config = defaultConfig;
}
//# sourceMappingURL=config.js.map

@@ -1,4 +0,4 @@

export { configure, resetToDefault } from './config';
export { measurePerformance } from './measure-render';
export { configure, resetToDefaults } from './config';
export { measureRenders, measurePerformance } from './measure-renders';
export { measureFunction } from './measure-function';
//# sourceMappingURL=index.js.map
import { performance } from 'perf_hooks';
import { config } from './config';
import { processRunResults } from './measure-helpers';
import { showFlagsOuputIfNeeded, writeTestStats } from './output';
import { showFlagsOutputIfNeeded, writeTestStats } from './output';
export async function measureFunction(fn, options) {
const stats = await measureFunctionInternal(fn, options);
await writeTestStats(stats, 'function');
if ((options === null || options === void 0 ? void 0 : options.writeFile) !== false) {
await writeTestStats(stats, 'function');
}
return stats;
}
export function measureFunctionInternal(fn, options) {
function measureFunctionInternal(fn, options) {
const runs = (options === null || options === void 0 ? void 0 : options.runs) ?? config.runs;
const warmupRuns = (options === null || options === void 0 ? void 0 : options.warmupRuns) ?? config.warmupRuns;
showFlagsOuputIfNeeded();
showFlagsOutputIfNeeded();
const runResults = [];

@@ -15,0 +17,0 @@ for (let i = 0; i < runs + warmupRuns; i += 1) {

import * as fs from 'fs/promises';
import { logger } from '@callstack/reassure-logger';
import * as logger from '@callstack/reassure-logger';
import { config } from './config';
export async function writeTestStats(stats, type) {
let outputFilePath = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : config.outputFile;
export async function writeTestStats(stats, type, outputFilePath = config.outputFile) {
const name = expect.getState().currentTestName;

@@ -19,4 +18,3 @@ const line = JSON.stringify({

}
export async function clearTestStats() {
let outputFilePath = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : config.outputFile;
export async function clearTestStats(outputFilePath = config.outputFile) {
try {

@@ -29,3 +27,3 @@ await fs.unlink(outputFilePath);

let hasShownFlagsOutput = false;
export function showFlagsOuputIfNeeded() {
export function showFlagsOutputIfNeeded() {
if (hasShownFlagsOutput) {

@@ -32,0 +30,0 @@ return;

@@ -16,4 +16,4 @@ /// <reference types="react" />

export declare function configure(customConfig: Partial<Config>): void;
export declare function resetToDefault(): void;
export declare function resetToDefaults(): void;
export {};
//# sourceMappingURL=config.d.ts.map

@@ -1,5 +0,6 @@

export { configure, resetToDefault } from './config';
export { measurePerformance } from './measure-render';
export { configure, resetToDefaults } from './config';
export { measureRenders, measurePerformance } from './measure-renders';
export { measureFunction } from './measure-function';
export type { MeasureOptions } from './measure-render';
export type { MeasureRendersOptions } from './measure-renders';
export type { MeasureFunctionOptions } from './measure-function';
//# sourceMappingURL=index.d.ts.map
import type { MeasureResults } from './types';
interface MeasureFunctionOptions {
export interface MeasureFunctionOptions {
runs?: number;
warmupRuns?: number;
writeFile?: boolean;
}
export declare function measureFunction(fn: () => void, options?: MeasureFunctionOptions): Promise<MeasureResults>;
export declare function measureFunctionInternal(fn: () => void, options?: MeasureFunctionOptions): MeasureResults;
export {};
//# sourceMappingURL=measure-function.d.ts.map
import type { MeasureResults, MeasureType } from './types';
export declare function writeTestStats(stats: MeasureResults, type: MeasureType, outputFilePath?: string): Promise<void>;
export declare function clearTestStats(outputFilePath?: string): Promise<void>;
export declare function showFlagsOuputIfNeeded(): void;
export declare function showFlagsOutputIfNeeded(): void;
export declare function resetHasShownFlagsOutput(): void;
//# sourceMappingURL=output.d.ts.map
{
"name": "@callstack/reassure-measure",
"version": "0.6.0",
"version": "1.0.0-beta",
"description": "Performance measurement library for React and React Native",

@@ -39,7 +39,7 @@ "main": "lib/commonjs/index",

"dependencies": {
"@callstack/reassure-logger": "0.3.1",
"@callstack/reassure-logger": "1.0.0-beta",
"mathjs": "^11.5.0"
},
"devDependencies": {
"react-native": "0.72.5"
"react-native": "0.73.1"
},

@@ -55,3 +55,8 @@ "peerDependencies": {

"module",
"typescript"
[
"typescript",
{
"project": "tsconfig.build.json"
}
]
]

@@ -58,0 +63,0 @@ },

@@ -29,4 +29,4 @@ export type TestingLibrary = 'react' | 'react-native' | { render: Render; cleanup: Cleanup };

export function resetToDefault() {
export function resetToDefaults() {
config = defaultConfig;
}

@@ -1,4 +0,5 @@

export { configure, resetToDefault } from './config';
export { measurePerformance } from './measure-render';
export { configure, resetToDefaults } from './config';
export { measureRenders, measurePerformance } from './measure-renders';
export { measureFunction } from './measure-function';
export type { MeasureOptions } from './measure-render';
export type { MeasureRendersOptions } from './measure-renders';
export type { MeasureFunctionOptions } from './measure-function';
import * as fs from 'fs/promises';
import { logger } from '@callstack/reassure-logger';
import * as logger from '@callstack/reassure-logger';
import { config } from './config';

@@ -32,3 +32,3 @@ import type { MeasureResults, MeasureType } from './types';

export function showFlagsOuputIfNeeded() {
export function showFlagsOutputIfNeeded() {
if (hasShownFlagsOutput) {

@@ -35,0 +35,0 @@ return;

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

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