मैं Benchmark.js का उपयोग कर नमूना प्रदर्शन बेंचमार्क निष्पादित करने का प्रयास कर रहा हूं। यहाँचक्रों की संख्या परिभाषित करें - Benchmark.js
@BenchmarkOptions(clock = Clock.NANO_TIME, callgc = true, benchmarkRounds = 10, warmupRounds = 1)
भी मैं benchmarkjs में benchmarkRounds
और warmupRounds
गिनती की घोषणा करना चाहते हैं: जैसे हम JUnitBenchmarks में क्या
var Benchmark = require('benchmark');
var arr = []
benchmark = new Benchmark('testPerf',function(){
arr.push(1000);
},
{
delay: 0,
initCount: 1,
minSamples: 1000,
onComplete : function(){ console.log(this);},
onCycle: function(){}
});
benchmark.run();
अब: यहाँ मैं क्या लिखा है। मुझे लगता है कि warmupRounds
नक्शे initCount
पर? और चक्र/बेंचमार्क पुनरावृत्ति की सटीक संख्या कैसे सेट करें?
या यदि हमारे पास कुछ अन्य अच्छी जावास्क्रिप्ट लाइब्रेरी है जो इसे संभाल सकती है तो यह भी काम करेगी।
जावास्क्रिप्ट में बेंचमार्किंग एक निश्चित पुनरावृत्ति संख्या का उपयोग कर रहा है [समस्याग्रस्त] (http://calendar.perfplanet.com/2010/bulletproof-javascript-benchmarks/), इसलिए Benchmark.js उस विकल्प की अनुमति नहीं है । इसके बजाए, यह बार-बार परीक्षण चलाता है [जब तक परिणाम उचित रूप से सटीक नहीं माना जा सकता] [http://monsur.hossa.in/2012/12/11/benchmarkjs.html)। – approxiblue
@approxiblue कृपया इस टिप्पणी को उत्तर के रूप में पोस्ट करें। – Tariq