Additional performance tests (#1512)
This commit is contained in:
@@ -1,7 +1,8 @@
|
||||
// Copyright 2017-2022 @polkadot/util authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { arrayChunk } from '.';
|
||||
import { performance } from '../test/performance';
|
||||
import { arrayChunk, arrayRange } from '.';
|
||||
|
||||
describe('arrayChunk', (): void => {
|
||||
it('chunks arrays', (): void => {
|
||||
@@ -9,4 +10,6 @@ describe('arrayChunk', (): void => {
|
||||
arrayChunk([1, 2, 3, 4, 5, 6, 7], 3)
|
||||
).toEqual([[1, 2, 3], [4, 5, 6], [7]]);
|
||||
});
|
||||
|
||||
performance('arrayChunk', 200_000, [[arrayRange(500), 50]], arrayChunk);
|
||||
});
|
||||
|
||||
@@ -4,10 +4,20 @@
|
||||
import { performance } from '../test/performance';
|
||||
import { u8aEq } from '.';
|
||||
|
||||
const ptest = new Uint8Array(32768);
|
||||
const ltest = new Uint8Array(32768);
|
||||
const stest = new Uint8Array(256);
|
||||
const ztest = new Uint8Array(64);
|
||||
|
||||
for (let i = 0; i < ptest.length; i++) {
|
||||
ptest[i] = i % 256;
|
||||
for (let i = 0; i < ltest.length; i++) {
|
||||
if (i < ztest.length) {
|
||||
ztest[i] = i % 256;
|
||||
}
|
||||
|
||||
if (i < stest.length) {
|
||||
stest[i] = i % 256;
|
||||
}
|
||||
|
||||
ltest[i] = i % 256;
|
||||
}
|
||||
|
||||
describe('u8aEq', (): void => {
|
||||
@@ -95,5 +105,7 @@ describe('u8aEq', (): void => {
|
||||
).toEqual(true);
|
||||
});
|
||||
|
||||
performance('u8aEq (32k cmp)', 50000, [[ptest, ptest]], u8aEq);
|
||||
performance('u8aEq (64 cmp)', 200_000, [[ztest, ztest]], u8aEq);
|
||||
performance('u8aEq (256 cmp)', 200_000, [[stest, stest]], u8aEq);
|
||||
performance('u8aEq (32k cmp)', 10_000, [[ltest, ltest]], u8aEq);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user