-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbasic.ts
More file actions
52 lines (41 loc) · 1.28 KB
/
basic.ts
File metadata and controls
52 lines (41 loc) · 1.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
/**
* Basic usage example - benchmark a single proxy.
*
* Usage:
* npx ts-node examples/basic.ts
*/
import { runBenchmark, parseProxyUrl } from '../src/benchmark';
import { formatReport } from '../src/reporter';
import { renderLatencyChart, renderHistogram } from '../src/chart';
async function main() {
// Parse proxy URL into a config object
const proxy = parseProxyUrl('http://user:pass@proxy.example.com:8080', 'My Proxy');
// Run benchmark with custom options
const report = await runBenchmark(
proxy,
{
targetUrl: 'https://httpbin.org/get',
requests: 20,
concurrency: 5,
timeout: 15000,
method: 'GET',
},
(completed, total) => {
process.stdout.write(`\rProgress: ${completed}/${total}`);
}
);
console.log('\n');
// Print formatted table report
console.log(formatReport(report, 'table'));
// Print latency distribution chart
console.log(renderLatencyChart(report));
// Print latency histogram
console.log(renderHistogram(report));
// Also available as JSON
// console.log(formatReport(report, 'json'));
// Or CSV for spreadsheet import
// console.log(formatReport(report, 'csv'));
// Or Markdown for documentation
// console.log(formatReport(report, 'markdown'));
}
main().catch(console.error);