Bug:Fix file validation issue
[vnfsdk/refrepo.git] / vnfmarket / src / main / webapp / vnfmarket / node_modules / tsscmp / test / benchmark / index.js
1 'use strict';
2
3 var timeSafeCompare = require('../../lib/index');
4
5 function random(length) {
6
7     length = length || 32;
8     var result = "";
9     var possible = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*()-+/*[]{}-=\|;\':\"<>?,./";
10
11     for( var i=0; i < length; i++ ){
12         result += possible.charAt(Math.floor(Math.random() * possible.length));
13     }
14     return result;
15 }
16
17 function run(count) {
18     count = count || 100*1000;
19     console.log('benchmark count: ' + count/1000 + 'k');
20     console.time('benchmark');
21     
22     while(count--){
23         timeSafeCompare(random(), random());
24     }
25     console.timeEnd('benchmark');
26 }
27
28 run(100000);
29
30 module.exports = run;