-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
perf(toolkit/uuid): use faster algorithm to generate UUID
closes #162
- Loading branch information
1 parent
ac9dd9e
commit 1fe7039
Showing
3 changed files
with
55 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/* | ||
* Copyright (c) 2018-2023 Swiss Federal Railways | ||
* | ||
* This program and the accompanying materials are made | ||
* available under the terms of the Eclipse Public License 2.0 | ||
* which is available at https://www.eclipse.org/legal/epl-2.0/ | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
*/ | ||
|
||
import {randomUUID} from './uuid.util'; | ||
|
||
describe('UUID', () => { | ||
|
||
it('should generate an UUID with 36 characters', () => { | ||
const uuid = randomUUID(); | ||
expect(uuid).not.toBeNull(); | ||
expect(uuid.length === 36).toBeTrue(); | ||
}); | ||
|
||
it('should generate 500_000 unique UUIDs', () => { | ||
// check uniqueness of 500.000 UUIDs | ||
const uuids = new Set(); | ||
for (let i = 0; i < 500_000; i++) { | ||
const uuid = randomUUID(); | ||
expect(uuids.has(uuid)).toBeFalse(); | ||
uuids.add(uuid); | ||
} | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters