Remove concatBuffer viariant (#1234)
This commit is contained in:
@@ -1,8 +1,9 @@
|
||||
// Copyright 2017-2021 @polkadot/util authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { performanceJs } from '../../test/performance';
|
||||
import { performanceCmp } from '../../test/performance';
|
||||
import { U16_TO_HEX } from './alphabet';
|
||||
import { hexToU8a as hexToU8aBuffer } from './toU8aBuffer';
|
||||
import { hexToU8a } from '.';
|
||||
|
||||
let ptest = '0x';
|
||||
@@ -54,5 +55,9 @@ describe('hexToU8a', (): void => {
|
||||
).toThrow(/hex value to convert/);
|
||||
});
|
||||
|
||||
performanceJs('hexToU8a (640k input)', 10, [[ptest]], hexToU8a);
|
||||
performanceCmp('hexToU8a (640k input)', ['Node + Buffer', 'Uint8Array'], 10, [[ptest]], (s: string, isSecond) =>
|
||||
isSecond
|
||||
? hexToU8a(s)
|
||||
: hexToU8aBuffer(s)
|
||||
);
|
||||
});
|
||||
|
||||
@@ -1,16 +1,8 @@
|
||||
// Copyright 2017-2021 @polkadot/util authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { performanceJs } from '../../test/performance';
|
||||
import { U16_TO_HEX } from './alphabet';
|
||||
import { hexToU8a } from './toU8aBuffer';
|
||||
|
||||
let ptest = '0x';
|
||||
|
||||
for (let i = 0; i < 640 * 1024; i++) {
|
||||
ptest += U16_TO_HEX[i % (256 * 256)];
|
||||
}
|
||||
|
||||
describe('hexToU8a', (): void => {
|
||||
it('returns an empty Uint8Array when null provided', (): void => {
|
||||
expect(
|
||||
@@ -47,6 +39,4 @@ describe('hexToU8a', (): void => {
|
||||
() => hexToU8a('notahex')
|
||||
).toThrow(/hex value to convert/);
|
||||
});
|
||||
|
||||
performanceJs('hexToU8a (Node Buffer, 640k input)', 10, [[ptest]], hexToU8a);
|
||||
});
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// Copyright 2017-2021 @polkadot/util authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { performanceJs } from '../../test/performance';
|
||||
import { performance } from '../../test/performance';
|
||||
import { isHex } from '.';
|
||||
|
||||
describe('isHex', (): void => {
|
||||
@@ -71,5 +71,5 @@ describe('isHex', (): void => {
|
||||
).toEqual(true);
|
||||
});
|
||||
|
||||
performanceJs('isHex (1024-bit)', 1000000, [[ptest]], isHex);
|
||||
performance('isHex (1024-bit)', 1000000, [[ptest]], isHex);
|
||||
});
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
import { randomAsNumber } from '@polkadot/util-crypto';
|
||||
import words from '@polkadot/util-crypto/mnemonic/bip39-en';
|
||||
|
||||
import { performanceJs } from '../../test/performance';
|
||||
import { performance } from '../../test/performance';
|
||||
import { arrayRange } from '../array';
|
||||
import { stringCamelCase, stringUpperFirst } from '.';
|
||||
|
||||
@@ -43,5 +43,5 @@ describe('stringCamelCase', (): void => {
|
||||
).toBe('fooBarBazTestSpacedExtra');
|
||||
});
|
||||
|
||||
performanceJs('stringCamelCase', 64000, randomWords, stringCamelCase);
|
||||
performance('stringCamelCase', 64000, randomWords, stringCamelCase);
|
||||
});
|
||||
|
||||
@@ -1,8 +1,14 @@
|
||||
// Copyright 2017-2021 @polkadot/util authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { randomAsU8a } from '@polkadot/util-crypto';
|
||||
|
||||
import { performance } from '../../test/performance';
|
||||
import { arrayRange } from '../array';
|
||||
import { u8aConcat } from '.';
|
||||
|
||||
const ptest = arrayRange(10).map(() => randomAsU8a());
|
||||
|
||||
describe('u8aConcat', (): void => {
|
||||
it('concatenates arrays', (): void => {
|
||||
expect(
|
||||
@@ -27,4 +33,6 @@ describe('u8aConcat', (): void => {
|
||||
new Uint8Array([1, 2, 3, 4, 5, 6, 7, 8, 9])
|
||||
);
|
||||
});
|
||||
|
||||
performance('u8aConcat', 50000, [[ptest]], u8aConcat);
|
||||
});
|
||||
|
||||
@@ -1,30 +0,0 @@
|
||||
// Copyright 2017-2021 @polkadot/util authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { u8aConcat } from './concatBuffer';
|
||||
|
||||
describe('u8aConcat', (): void => {
|
||||
it('concatenates arrays', (): void => {
|
||||
expect(
|
||||
u8aConcat(
|
||||
new Uint8Array([1, 2, 3, 4]),
|
||||
new Uint8Array([5, 6]),
|
||||
new Uint8Array([7, 8, 9])
|
||||
)
|
||||
).toEqual(
|
||||
new Uint8Array([1, 2, 3, 4, 5, 6, 7, 8, 9])
|
||||
);
|
||||
});
|
||||
|
||||
it('concatenates arrays & hex values', (): void => {
|
||||
expect(
|
||||
u8aConcat(
|
||||
new Uint8Array([1, 2, 3, 4]),
|
||||
'0x0506',
|
||||
'0x070809'
|
||||
)
|
||||
).toEqual(
|
||||
new Uint8Array([1, 2, 3, 4, 5, 6, 7, 8, 9])
|
||||
);
|
||||
});
|
||||
});
|
||||
@@ -1,7 +1,7 @@
|
||||
// Copyright 2017-2021 @polkadot/util authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { performanceJs } from '../../test/performance';
|
||||
import { performance } from '../../test/performance';
|
||||
import { u8aEq } from '.';
|
||||
|
||||
const ptest = new Uint8Array(32768);
|
||||
@@ -95,5 +95,5 @@ describe('u8aEq', (): void => {
|
||||
).toEqual(true);
|
||||
});
|
||||
|
||||
performanceJs('u8aEq (32k cmp)', 50000, [[ptest, ptest]], u8aEq);
|
||||
performance('u8aEq (32k cmp)', 50000, [[ptest, ptest]], u8aEq);
|
||||
});
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
// Copyright 2017-2021 @polkadot/util authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { performanceJs } from '../../test/performance';
|
||||
import { performanceCmp } from '../../test/performance';
|
||||
import { u8aToHex as u8aToHexBuffer } from './toHexBuffer';
|
||||
import { u8aToHex } from '.';
|
||||
|
||||
const ptest = new Uint8Array(32768);
|
||||
@@ -65,5 +66,9 @@ describe('u8aToHex', (): void => {
|
||||
).toEqual('0x8000…0c0d');
|
||||
});
|
||||
|
||||
performanceJs('u8aToHex (32k input)', 2000, [[ptest]], u8aToHex);
|
||||
performanceCmp('u8aToHex (32k input)', ['Node + Buffer', 'Uint8Array'], 2000, [[ptest]], (s: Uint8Array, isSecond) =>
|
||||
isSecond
|
||||
? u8aToHex(s)
|
||||
: u8aToHexBuffer(s)
|
||||
);
|
||||
});
|
||||
|
||||
@@ -1,15 +1,8 @@
|
||||
// Copyright 2017-2021 @polkadot/util authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { performanceJs } from '../../test/performance';
|
||||
import { u8aToHex } from './toHexBuffer';
|
||||
|
||||
const ptest = new Uint8Array(32768);
|
||||
|
||||
for (let i = 0; i < ptest.length; i++) {
|
||||
ptest[i] = i % 256;
|
||||
}
|
||||
|
||||
describe('u8aToHex', (): void => {
|
||||
it('returns empty as 0x', (): void => {
|
||||
expect(
|
||||
@@ -64,6 +57,4 @@ describe('u8aToHex', (): void => {
|
||||
)
|
||||
).toEqual('0x8000…0c0d');
|
||||
});
|
||||
|
||||
performanceJs('u8aToHex (Node Buffer, 32k input)', 2000, [[ptest]], u8aToHex);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user