summaryrefslogtreecommitdiff
path: root/perf
diff options
context:
space:
mode:
authoryemreinci <18687880+yemreinci@users.noreply.github.com>2018-11-21 07:28:32 +0300
committerAlex Early <alexander.early@gmail.com>2018-11-20 20:28:32 -0800
commita5a9f13ee024e58a3bd074f9c4e0130f0499d27b (patch)
treef88fbadbf2b5a6d0574c19d531b94e520cea3777 /perf
parent884b040c22bb27f69d9136bf4391a79a16911c12 (diff)
downloadasync-a5a9f13ee024e58a3bd074f9c4e0130f0499d27b.tar.gz
feat: Use heap tree in priority queue (#1595)
* use heap tree in priority queue * small refactor
Diffstat (limited to 'perf')
-rw-r--r--perf/suites.js31
1 files changed, 31 insertions, 0 deletions
diff --git a/perf/suites.js b/perf/suites.js
index d3cb4e9..1171939 100644
--- a/perf/suites.js
+++ b/perf/suites.js
@@ -303,6 +303,37 @@ module.exports = [{
}
}
}, {
+ name: "priorityQueue",
+ args: [
+ [10],
+ [100],
+ [1000],
+ [30000],
+ [50000]
+ ],
+ setup: function setup(num) {
+ tasks = num;
+ },
+ fn(async, done) {
+ var numEntries = tasks;
+ var q = async.priorityQueue(worker, 1);
+ for (var i = 1; i <= numEntries; i++) {
+ q.push({
+ num: i
+ }, i);
+ }
+
+ var completedCnt = 0;
+
+ function worker(task, callback) {
+ completedCnt++;
+ if (completedCnt === numEntries) {
+ return done();
+ }
+ setImmediate(callback);
+ }
+ }
+}, {
name: "some - no short circuit- false",
// args lists are passed to the setup function
args: [