mirror of
https://github.com/zrwusa/data-structure-typed.git
synced 2024-11-23 12:54:04 +00:00
test: HashMap test case conducted on million data
This commit is contained in:
parent
cbf1d05064
commit
b7357def44
|
@ -5,42 +5,42 @@ import { magnitude } from '../../../utils';
|
|||
import { isCompetitor } from '../../../config';
|
||||
|
||||
const suite = new Benchmark.Suite();
|
||||
const { TEN_THOUSAND } = magnitude;
|
||||
const { MILLION } = magnitude;
|
||||
|
||||
suite.add(`${TEN_THOUSAND.toLocaleString()} set`, () => {
|
||||
suite.add(`${MILLION.toLocaleString()} set`, () => {
|
||||
const hm = new HashMap<number, number>();
|
||||
|
||||
for (let i = 0; i < TEN_THOUSAND; i++) {
|
||||
for (let i = 0; i < MILLION; i++) {
|
||||
hm.set(i, i);
|
||||
}
|
||||
});
|
||||
if (isCompetitor) {
|
||||
suite.add(`${TEN_THOUSAND.toLocaleString()} CPT set`, () => {
|
||||
suite.add(`${MILLION.toLocaleString()} CPT set`, () => {
|
||||
const hm = new CHashMap<number, number>();
|
||||
|
||||
for (let i = 0; i < TEN_THOUSAND; i++) {
|
||||
for (let i = 0; i < MILLION; i++) {
|
||||
hm.setElement(i, i);
|
||||
}
|
||||
});
|
||||
}
|
||||
suite.add(`${TEN_THOUSAND.toLocaleString()} set & get`, () => {
|
||||
suite.add(`${MILLION.toLocaleString()} set & get`, () => {
|
||||
const hm = new HashMap<number, number>();
|
||||
|
||||
for (let i = 0; i < TEN_THOUSAND; i++) {
|
||||
for (let i = 0; i < MILLION; i++) {
|
||||
hm.set(i, i);
|
||||
}
|
||||
for (let i = 0; i < TEN_THOUSAND; i++) {
|
||||
for (let i = 0; i < MILLION; i++) {
|
||||
hm.get(i);
|
||||
}
|
||||
});
|
||||
if (isCompetitor) {
|
||||
suite.add(`${TEN_THOUSAND.toLocaleString()} CPT set & get`, () => {
|
||||
suite.add(`${MILLION.toLocaleString()} CPT set & get`, () => {
|
||||
const hm = new CHashMap<number, number>();
|
||||
|
||||
for (let i = 0; i < TEN_THOUSAND; i++) {
|
||||
for (let i = 0; i < MILLION; i++) {
|
||||
hm.setElement(i, i);
|
||||
}
|
||||
for (let i = 0; i < TEN_THOUSAND; i++) {
|
||||
for (let i = 0; i < MILLION; i++) {
|
||||
hm.getElementByKey(i);
|
||||
}
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue