Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

spica

Package Overview
Dependencies
Maintainers
1
Versions
804
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

spica - npm Package Compare versions

Comparing version 0.0.766 to 0.0.767

63

cache.test.ts

@@ -408,3 +408,3 @@ import { Cache } from './cache';

const trials = capacity * 1000;
const zipf = zipfian(1, capacity * 1e3, 0.8, xorshift.random(1));
const zipf = zipfian(1, capacity * 1e2, 0.8, xorshift.random(1));
const stats = new Stats();

@@ -425,3 +425,3 @@ for (let i = 0; i < trials; ++i) {

console.debug('DWC overlap', dwc['overlapLRU'], dwc['overlapLFU']);
assert(stats.dwc / stats.lru * 100 >>> 0 === 194);
assert(stats.dwc / stats.lru * 100 >>> 0 === 155);
});

@@ -437,9 +437,9 @@

const trials = capacity * 1000;
const zipf = zipfian(1, capacity * 1e3, 0.8, xorshift.random(1));
const zipf = zipfian(1, capacity * 1e2, 0.8, xorshift.random(1));
const random = xorshift.random(1);
const stats = new Stats();
for (let i = 0; i < trials; ++i) {
const key = random() < 0.5
const key = i % 2
? zipf()
: -random() * capacity * 10 - i * capacity / 100 | 0;
: -random() * capacity * 10 - (i / 2 | 0) * capacity / 100 / 10 | 0;
stats.lru += lru.get(key) ?? +lru.set(key, 1) & 0;

@@ -457,3 +457,3 @@ stats.dwc += dwc.get(key) ?? +dwc.set(key, 1) & 0;

console.debug('DWC overlap', dwc['overlapLRU'], dwc['overlapLFU']);
assert(stats.dwc / stats.lru * 100 >>> 0 === 89);
assert(stats.dwc / stats.lru * 100 >>> 0 === 133);
});

@@ -469,10 +469,10 @@

const trials = capacity * 1000;
const zipf = zipfian(1, capacity * 1e3, 0.8, xorshift.random(1));
const zipf = zipfian(1, capacity * 1e2, 0.8, xorshift.random(1));
const random = xorshift.random(1);
const stats = new Stats();
for (let i = 0; i < trials; ++i) {
const key = random() < 0.5
const key = i % 2
// 推移的偏りはこれを迅速に捕捉し続けるLRUと保持するLFUが必要であるため偏りの2倍の履歴が必要となる
? zipf() + i / 2 * capacity * 1e3 / 100 | 0
: -random() * capacity * 10 | 0;
? capacity * 1e2 - zipf() + (i / 2 | 0) * capacity / 100 / 10 | 0
: -random() * capacity * 10 - 1 | 0;
stats.lru += lru.get(key) ?? +lru.set(key, 1) & 0;

@@ -490,3 +490,3 @@ stats.dwc += dwc.get(key) ?? +dwc.set(key, 1) & 0;

console.debug('DWC overlap', dwc['overlapLRU'], dwc['overlapLFU']);
assert(stats.dwc / stats.lru * 100 >>> 0 === 161);
assert(stats.dwc / stats.lru * 100 >>> 0 === 68);
});

@@ -501,4 +501,4 @@

const trials = capacity * 1000;
const zipf = zipfian(1, capacity * 1e3, 0.8, xorshift.random(1));
const trials = capacity * 100;
const zipf = zipfian(1, capacity * 1e2, 0.8, xorshift.random(1));
const stats = new Stats();

@@ -509,3 +509,3 @@ for (let i = 0; i < trials; ++i) {

// 容量1000でほぼ完全に相殺
? i % 3 - 1 ? i - i % 3 + 6 : i - i % 3
? i % 3 - 2 ? i - i % 3 : i - i % 3 + 6
: -zipf();

@@ -524,3 +524,3 @@ stats.lru += lru.get(key) ?? +lru.set(key, 1) & 0;

console.debug('DWC overlap', dwc['overlapLRU'], dwc['overlapLFU']);
assert(stats.dwc / stats.lru * 100 >>> 0 === 22);
assert(stats.dwc / stats.lru * 100 >>> 0 === 28);
});

@@ -570,2 +570,3 @@

stats.total += 1;
i + 1 === trials - capacity * 10 && stats.clear();
}

@@ -581,3 +582,3 @@ assert(dwc['LRU'].length + dwc['LFU'].length === dwc['dict'].size);

assert(stats.dwc / stats.lru * 100 === Infinity);
assert(stats.dwc * 100 / stats.total >>> 0 === 4);
assert(stats.dwc * 100 / stats.total >>> 0 === 9);
});

@@ -588,3 +589,2 @@

// キャッシュサイズが相対的に小さい場合はサンプルの挿入とヒットによりアンロックされる
// 容量100でのテストは確率的および統計的にかなり悪条件

@@ -628,3 +628,3 @@ // 統計汚染

stats.total += 1;
i + 1 === trials / 2 && stats.clear();
i + 1 === trials - capacity * 10 && stats.clear();
}

@@ -639,3 +639,3 @@ assert(dwc['LRU'].length + dwc['LFU'].length === dwc['dict'].size);

console.debug('DWC overlap', dwc['overlapLRU'], dwc['overlapLFU']);
assert(stats.dwc / stats.lru * 100 >>> 0 === 22);
assert(stats.dwc / stats.lru * 100 >>> 0 === 24);
});

@@ -658,3 +658,3 @@

stats.total += 1;
i + 1 === trials / 2 && stats.clear();
i + 1 === trials - capacity * 10 && stats.clear();
}

@@ -670,3 +670,3 @@ assert(dwc['LRU'].length + dwc['LFU'].length === dwc['dict'].size);

assert(stats.dwc / stats.lru * 100 === Infinity);
assert(stats.dwc * 100 / stats.total >>> 0 === 7);
assert(stats.dwc * 100 / stats.total >>> 0 === 9);
assert(dwc['partition']! * 100 / capacity >>> 0 === 0);

@@ -693,3 +693,3 @@ });

stats.total += 1;
i + 1 === trials / 2 && stats.clear();
i + 1 === trials - capacity * 10 && stats.clear();
}

@@ -704,3 +704,3 @@ assert(dwc['LRU'].length + dwc['LFU'].length === dwc['dict'].size);

console.debug('DWC overlap', dwc['overlapLRU'], dwc['overlapLFU']);
assert(stats.dwc / stats.lru * 100 >>> 0 === 62);
assert(stats.dwc / stats.lru * 100 >>> 0 === 110);
assert(dwc['partition']! * 100 / capacity >>> 0 === 99);

@@ -717,11 +717,10 @@ });

const trials = capacity * 20;
const random = xorshift.random(1);
const trials = capacity * 40;
const stats = new Stats();
for (let i = 0; i < trials; ++i) {
const key = i % 2
? -i % capacity / 2 - 1 | 0
// 低ヒット率のLIRで高ヒット率のHIRの捕捉を妨害
: random() < 0.5
? random() * capacity / 10 | 0
// 高ヒット率のLIRで低ヒット率のHIRの捕捉を妨害
? -(i / 2 | 0) % (capacity / 4 | 0) - 1 | 0
: i % 4
? i % (capacity / 2 | 0) | 0
: i + capacity;

@@ -731,3 +730,3 @@ stats.lru += lru.get(key) ?? +lru.set(key, 1) & 0;

stats.total += 1;
i + 1 === trials / 2 && stats.clear();
i + 1 === trials - capacity * 10 && stats.clear();
}

@@ -742,4 +741,4 @@ assert(dwc['LRU'].length + dwc['LFU'].length === dwc['dict'].size);

console.debug('DWC overlap', dwc['overlapLRU'], dwc['overlapLFU']);
assert(stats.dwc / stats.lru * 100 >>> 0 === 98);
assert(dwc['partition']! * 100 / capacity >>> 0 === 99);
assert(stats.dwc / stats.lru * 100 >>> 0 === 100);
assert(dwc['partition']! * 100 / capacity >>> 0 === 0);
});

@@ -746,0 +745,0 @@

@@ -446,3 +446,3 @@ import { max, min, floor, round } from './alias';

assert(this.overlapLFU > 0);
const delta = LRU.length >= this.capacity - this.partition
const delta = LFU.length <= this.partition
? max(LRU.length / (LFU.length || 1) * max(this.overlapLRU / this.overlapLFU, 1) | 0, 1)

@@ -465,3 +465,3 @@ : 0;

assert(this.overlapLRU > 0);
const delta = LFU.length >= this.partition
const delta = LRU.length <= this.capacity - this.partition
? max(LFU.length / (LRU.length || 1) * max(this.overlapLFU / this.overlapLRU, 1) | 0, 1)

@@ -468,0 +468,0 @@ : 0;

{
"name": "spica",
"version": "0.0.766",
"version": "0.0.767",
"description": "Supervisor, Coroutine, Channel, select, AtomicPromise, Cancellation, Cache, List, Queue, Stack, and some utils.",

@@ -5,0 +5,0 @@ "private": false,

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc