Comparing version
@@ -0,1 +1,3 @@ | ||
var assert = require('assert'); | ||
var QlobberOpts = { | ||
@@ -57,8 +59,17 @@ wildcard_one: '+', | ||
{ | ||
console.log(match(matcher, 'a/b/c/public/test').length); | ||
assert.strictEqual(match(matcher, 'a/b/c/public/test').length, 299990); | ||
} | ||
} | ||
function times(QlobberClass, add, remove, match) | ||
function test_public_topics(matcher, test) | ||
{ | ||
for (var i = 0; i < 300000; i += 1) | ||
{ | ||
var clientId = 'someClientId/' + i; | ||
assert.strictEqual(test(matcher, clientId, 'a/b/c/public/test'), false); | ||
} | ||
} | ||
function times(QlobberClass, add, remove, match, test) | ||
{ | ||
gc(); | ||
@@ -73,2 +84,3 @@ var start_mem = process.memoryUsage(); | ||
time(match_public_topics, matcher, match); | ||
time(test_public_topics, matcher, test); | ||
@@ -75,0 +87,0 @@ gc(); |
@@ -27,2 +27,27 @@ var QlobberDedup = require('../..').QlobberDedup; | ||
times(QlobberDedup, add, remove, match); | ||
function test(matcher, clientId, topic) | ||
{ | ||
var count = 0; | ||
var found = false; | ||
for (var m of matcher.match(topic)) | ||
{ | ||
var parts = m.split(';'); | ||
if (parts[1] === topic) | ||
{ | ||
count += 1; | ||
if (count > 1) | ||
{ | ||
return false; | ||
} | ||
if (parts[0] === clientId) | ||
{ | ||
found = true; | ||
} | ||
} | ||
} | ||
return (count === 1) && found; | ||
} | ||
times(QlobberDedup, add, remove, match, test); |
@@ -28,2 +28,7 @@ var QlobberSub = require('../qlobber-sub.js'); | ||
times(QlobberSub, add, remove, match); | ||
function test(matcher, clientId, topic) | ||
{ | ||
return matcher.test(topic, { clientId: clientId, topic: topic }); | ||
} | ||
times(QlobberSub, add, remove, match, test); |
@@ -64,2 +64,3 @@ /*jslint node: true */ | ||
return (existing.topic === val.topic) && | ||
(existing.clientMap.size === 1) && | ||
existing.clientMap.has(val.clientId); | ||
@@ -66,0 +67,0 @@ }; |
@@ -11,3 +11,4 @@ /*jslint node: true */ | ||
options: { | ||
esversion: 6 | ||
esversion: 6, | ||
node: true | ||
} | ||
@@ -14,0 +15,0 @@ }, |
{ | ||
"name": "qlobber", | ||
"description": "Node.js globbing for amqp-like topics", | ||
"version": "1.4.0", | ||
"version": "1.5.0", | ||
"homepage": "https://github.com/davedoesdev/qlobber", | ||
@@ -6,0 +6,0 @@ "author": { |
@@ -99,3 +99,3 @@ /*jshint node: true, mocha: true */ | ||
topic: 'foo.bar' | ||
})).to.equal(true); | ||
})).to.equal(false); | ||
expect(matcher.test('foo.bar', | ||
@@ -105,3 +105,3 @@ { | ||
topic: 'foo.bar' | ||
})).to.equal(true); | ||
})).to.equal(false); | ||
}); | ||
@@ -290,6 +290,2 @@ | ||
}); | ||
}); |
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
234562
1.84%54
3.85%2880
5.22%