jsPerf.app is an online JavaScript performance benchmark test runner & jsperf.com mirror. It is a complete rewrite in homage to the once excellent jsperf.com now with hopefully a more modern & maintainable codebase.
jsperf.com URLs are mirrored at the same path, e.g:
https://jsperf.com/negative-modulo/2
Can be accessed at:
https://jsperf.app/negative-modulo/2
function createLinkedList(length) {
if (length <= 0) {
return null;
}
// Возможные символы и направления
const symbols = ["SBER_TQBR", "GAZP_TQBR", "LKOH_TQBR", "YNDX_TQBR", "ROSN_TQBR"];
const directions = ["BUY", "SELL"];
let head = null;
let current = null;
let baseTimestamp = Date.now() * 1000; // Начальный timestamp в микросекундах
for (let i = 0; i < length; i++) {
// Генерируем случайные данные
const symbol = symbols[Math.floor(Math.random() * symbols.length)];
const direction = directions[Math.floor(Math.random() * directions.length)];
const price = +(Math.random() * 500 + 100).toFixed(2); // Цена от 100 до 600
const quantity = Math.floor(Math.random() * 50) + 1; // Количество от 1 до 50
const timestamp = baseTimestamp + i * 1000000; // Увеличиваем на 1 секунду каждый раз
// Создаем новый узел
const node = {
s: symbol,
d: direction,
p: price,
q: quantity,
ts: timestamp,
src: "t",
seq: timestamp,
next: null
};
// Если это первый узел
if (head === null) {
head = node;
current = node;
} else {
// Присоединяем к цепочке
current.next = node;
current = node;
}
}
return head;
}
function createTradeArray(length) {
if (length <= 0) {
return [];
}
// Возможные символы и направления
const symbols = ["SBER_TQBR", "GAZP_TQBR", "LKOH_TQBR", "YNDX_TQBR", "ROSN_TQBR"];
const directions = ["BUY", "SELL"];
const trades = [];
let baseTimestamp = Date.now() * 1000; // Начальный timestamp в микросекундах
for (let i = 0; i < length; i++) {
// Генерируем случайные данные
const symbol = symbols[Math.floor(Math.random() * symbols.length)];
const direction = directions[Math.floor(Math.random() * directions.length)];
const price = +(Math.random() * 500 + 100).toFixed(2); // Цена от 100 до 600
const quantity = Math.floor(Math.random() * 50) + 1; // Количество от 1 до 50
const timestamp = baseTimestamp + i * 1000000; // Увеличиваем на 1 секунду каждый раз
// Создаем объект трейда (без поля next)
const trade = {
s: symbol,
d: direction,
p: price,
q: quantity,
ts: timestamp,
src: "t",
seq: timestamp
};
trades.push(trade);
}
return trades;
}
const list200 = JSON.stringify(createLinkedList(200));
const list500 = JSON.stringify(createLinkedList(500));
const list1000 = JSON.stringify(createLinkedList(1000));
const arr200 = JSON.stringify(createTradeArray(200));
const arr500 = JSON.stringify(createTradeArray(500));
const arr1000 = JSON.stringify(createTradeArray(1000));
function* linkedListGenerator(head) {
let current = head;
while (current) {
yield current;
current = current.next;
}
}
Ready to run.
| Test | Ops/sec | |
|---|---|---|
| 200 list | | ready |
| 200 arr | | ready |
| 500 list | | ready |
| 500 arr | | ready |
| 1000 list | | ready |
| 1000 arr | | ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.