Upload Kmake

This commit is contained in:
Gorochu
2026-05-26 23:36:42 -07:00
parent ba051b2f74
commit 555ec72358
41615 changed files with 13344630 additions and 1 deletions

38
benchmark/http2/compat.js Normal file
View File

@ -0,0 +1,38 @@
'use strict';
const common = require('../common.js');
const path = require('path');
const fs = require('fs');
const file = path.join(path.resolve(__dirname, '../fixtures'), 'alice.html');
const bench = common.createBenchmark(main, {
requests: [100, 1000, 5000],
streams: [1, 10, 20, 40, 100, 200],
clients: [2],
benchmarker: ['test-double-http2'],
duration: 5,
}, { flags: ['--no-warnings'] });
function main({ requests, streams, clients, duration }) {
const http2 = require('http2');
const server = http2.createServer();
server.on('request', (req, res) => {
const out = fs.createReadStream(file);
res.setHeader('content-type', 'text/html');
out.pipe(res);
out.on('error', (err) => {
res.destroy();
});
});
server.listen(0, () => {
bench.http({
path: '/',
port: server.address().port,
requests,
maxConcurrentStreams: streams,
clients,
threads: clients,
duration,
}, () => { server.close(); });
});
}

View File

@ -0,0 +1,56 @@
'use strict';
const common = require('../common.js');
const bench = common.createBenchmark(main, {
n: [1e3],
nheaders: [0, 10, 100, 1000],
}, { flags: ['--no-warnings'] });
function main({ n, nheaders }) {
const http2 = require('http2');
const server = http2.createServer({
maxHeaderListPairs: 20000,
});
const headersObject = {
':path': '/',
':scheme': 'http',
'accept-encoding': 'gzip, deflate',
'accept-language': 'en',
'content-type': 'text/plain',
'referer': 'https://example.org/',
'user-agent': 'SuperBenchmarker 3000',
};
for (let i = 0; i < nheaders; i++) {
headersObject[`foo${i}`] = `some header value ${i}`;
}
server.on('stream', (stream) => {
stream.respond();
stream.end('Hi!');
});
server.listen(0, () => {
const client = http2.connect(`http://localhost:${server.address().port}/`, {
maxHeaderListPairs: 20000,
});
function doRequest(remaining) {
const req = client.request(headersObject);
req.resume();
req.on('end', () => {
if (remaining > 0) {
doRequest(remaining - 1);
} else {
bench.end(n);
server.close();
client.destroy();
}
});
}
bench.start();
doRequest(n);
});
}

View File

@ -0,0 +1,42 @@
'use strict';
const common = require('../common.js');
const path = require('path');
const fs = require('fs');
const file = path.join(path.resolve(__dirname, '../fixtures'), 'alice.html');
const bench = common.createBenchmark(main, {
requests: [100, 1000, 5000],
streams: [1, 10, 20, 40, 100, 200],
clients: [2],
benchmarker: ['test-double-http2'],
duration: 5,
}, { flags: ['--no-warnings'] });
function main({ requests, streams, clients, duration }) {
fs.open(file, 'r', (err, fd) => {
if (err)
throw err;
const http2 = require('http2');
const server = http2.createServer();
server.on('stream', (stream) => {
stream.respondWithFD(fd);
stream.on('error', (err) => {});
});
server.listen(0, () => {
bench.http({
path: '/',
requests,
port: server.address().port,
maxConcurrentStreams: streams,
clients,
duration,
threads: clients,
}, () => server.close());
});
});
}

36
benchmark/http2/simple.js Normal file
View File

@ -0,0 +1,36 @@
'use strict';
const common = require('../common.js');
const path = require('path');
const fs = require('fs');
const file = path.join(path.resolve(__dirname, '../fixtures'), 'alice.html');
const bench = common.createBenchmark(main, {
requests: [100, 1000, 5000],
streams: [1, 10, 20, 40, 100, 200],
clients: [2],
benchmarker: ['test-double-http2'],
duration: 5,
}, { flags: ['--no-warnings'] });
function main({ requests, streams, clients, duration }) {
const http2 = require('http2');
const server = http2.createServer();
server.on('stream', (stream) => {
const out = fs.createReadStream(file);
stream.respond();
out.pipe(stream);
stream.on('error', (err) => {});
});
server.listen(0, () => {
bench.http({
path: '/',
port: server.address().port,
requests,
maxConcurrentStreams: streams,
clients,
duration,
threads: clients,
}, () => { server.close(); });
});
}

38
benchmark/http2/write.js Normal file
View File

@ -0,0 +1,38 @@
'use strict';
const common = require('../common.js');
const bench = common.createBenchmark(main, {
streams: [100, 200, 1000],
length: [64 * 1024, 128 * 1024, 256 * 1024, 1024 * 1024],
size: [100000],
benchmarker: ['test-double-http2'],
duration: 5,
}, { flags: ['--no-warnings'] });
function main({ streams, length, size, duration }) {
const http2 = require('http2');
const server = http2.createServer();
server.on('stream', (stream) => {
stream.respond();
let written = 0;
function write() {
stream.write('ü'.repeat(size));
written += size;
if (written < length)
setImmediate(write);
else
stream.end();
}
write();
});
server.listen(0, () => {
bench.http({
path: '/',
port: server.address().port,
requests: 10000,
duration,
maxConcurrentStreams: streams,
}, () => { server.close(); });
});
}