MCPcopy Create free account
hub / github.com/avoidwork/tenso / concurrentRateCheck

Function concurrentRateCheck

benchmarks/rate-limiting.js:277–295  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

275 const rateStore = new Map();
276
277 const concurrentRateCheck = clientCount => {
278 const currentTime = Math.floor(Date.now() / 1000);
279
280 for (let i = 0; i < clientCount; i++) {
281 const clientId = `client-${i}`;
282
283 if (!rateStore.has(clientId)) {
284 rateStore.set(clientId, {
285 remaining: 100,
286 reset: currentTime + 900
287 });
288 }
289
290 const state = rateStore.get(clientId);
291 if (state.remaining > 0) {
292 state.remaining--;
293 }
294 }
295 };
296
297 suite
298 .add("Rate Limit - 10 concurrent clients", () => {

Callers 1

benchmarkHighConcurrencyFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected