-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7f8a640
commit 347f282
Showing
1 changed file
with
18 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,31 @@ | ||
// performanceTest.js | ||
const { performance } = require('perf_hooks'); | ||
const assert = require('assert'); | ||
const Checker = require('../../src/checker'); | ||
|
||
const { performance } = require('perf_hooks') | ||
const assert = require('assert') | ||
const Checker = require('../../src/checker') | ||
|
||
describe('Performance Checker', () => { | ||
|
||
const testPerformance = (func, arg) => { | ||
const startTime = performance.now(); | ||
const startTime = performance.now() | ||
for (let i = 0; i < 1000000; i++) { | ||
func(arg); | ||
func(arg) | ||
} | ||
const endTime = performance.now(); | ||
const executionTime = endTime - startTime; | ||
const endTime = performance.now() | ||
const executionTime = endTime - startTime | ||
|
||
it(`Does not allow execution more than 1 second for ${func.name}`, () => { | ||
console.log(`Execution time for ${func.name}: ${executionTime} milliseconds`); | ||
assert(executionTime < 1000, `${func.name} took more than 1 second to execute.`); | ||
//console.log(`Execution time for ${func.name}: ${executionTime} milliseconds`) | ||
assert(executionTime < 1000, `${func.name} took more than 1 second to execute.`) | ||
}) | ||
} | ||
|
||
const testValue = 'test'; | ||
testPerformance(Checker.isFunction, testValue); | ||
testPerformance(Checker.isDefined, testValue); | ||
testPerformance(Checker.isArray, testValue); | ||
testPerformance(Checker.isArrayWithType, testValue); | ||
testPerformance(Checker.isIterable, testValue); | ||
testPerformance(Checker.isArrayWithTypeValid, testValue); | ||
testPerformance(Checker.isString, testValue); | ||
testPerformance(Checker.isBoolean, testValue); | ||
|
||
|
||
const testValue = 'test' | ||
testPerformance(Checker.isFunction, testValue) | ||
testPerformance(Checker.isDefined, testValue) | ||
testPerformance(Checker.isArray, testValue) | ||
testPerformance(Checker.isArrayWithType, testValue) | ||
testPerformance(Checker.isIterable, testValue) | ||
testPerformance(Checker.isString, testValue) | ||
testPerformance(Checker.isBoolean, testValue) | ||
}) | ||
|