Files
bun.sh/misctools/machbench.zig
dave caruso 441612917d windows: more windows stuff (#6938)
* fix(win/upgrade): do not show powershell expand-archive info while upgrading

* start working bun run

* experiment: `bun.new`

* you can now bun run

* Update src/install/install.zig

Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>

* Update src/install/install.zig

Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>

* stuff

* fix stuff

* fix this

* farther but not really

* sadfs

* path hell

not sure how much worse or better this makes things. its a mess. windows path handlign is a mess aaaaaaaaaaaaaaaa

* path.resolve bs

* remove old build system stuff from pr

* a

* fix some path.parse/join cases

* path closer not perfect

* normalize and join tests tests  done

* paths

* implement path.relative

* ,

* stuff

* assert

* fix compile

* hate

* the code isnt great

* stuff

* housekeeping for build system

* blah

* explain windows sitaution in docs

* some progress? not much though

* zig compiler crashes here

* fix

* yippee

* ok

* a

* ala wala

* fix builds on stuff

* clean

* the tests now run

* a

* aa

* dedupe uv event loop

* fix fs test accuracy

* stuff

* [autofix.ci] apply automated fixes

* huge updat e

* [autofix.ci] apply automated fixes

* url

* [autofix.ci] apply automated fixes

* start windows spawnSync

* [autofix.ci] apply automated fixes

* add --webkit for update submodules

* add better err message for `bun setup`

* fix unix platform build

* .

* [autofix.ci] apply automated fixes

* un-upgrade libarchive

* z

* asdfghj

* wrk

* todo -> panic

* ok

* a

* [autofix.ci] apply automated fixes

* fix build scripts l ol

* dfghj

* fa

* [autofix.ci] apply automated fixes

* aaaa

* a

* l

* [autofix.ci] apply automated fixes

* more logs

* [autofix.ci] apply automated fixes

* j

* fix init_command

* CORE DUMP HELL

* i swear im being pranked by the github actions gods

* fadsjkfdshjkhjkdfsahjkdfshjksdafjkhhjkfdsahfsdkjhfsdjkahf

* thanks IAS

* this is the correct fix

* personal review

* ddisablbe these

* revisions!

* ok

* fix submodule

* stuff

* fix libarchive

* [autofix.ci] apply automated fixes

* stuff

* [autofix.ci] apply automated fixes

* a

* fix addressToJS on windows

* make dns async again

* dx: add flag to update submodules ps1 to clone webkit

* dns error case for libuv

* dx improvements on windows

* newline

* obvious fix

* install steps

* extra note

* fix fs test

* Update building-windows.md

* fix builtins bundler to support \r\n line endnigs

* better

* some windows stuff

* a

* a

* a

* aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa

* [autofix.ci] apply automated fixes

* bunfile text works

* fix build on the mac

* hellooooooooooo

* install steps

* ci for baseline?

* fix

* aaa

* wow

* install script revamp

* bug

* OK

* ok

* aaaaaaaaaaaaaa

* okay

* fix the node test runner lol

* fix napi stuff

---------

Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Co-authored-by: cirospaciari <ciro.spaciai@gmail.com>
Co-authored-by: Dylan Conway <35280289+dylan-conway@users.noreply.github.com>
2023-12-14 16:56:33 -08:00

137 lines
4.5 KiB
Zig

// most of this file is copy pasted from other files in misctools
const std = @import("std");
const bun = @import("root").bun;
const string = bun.string;
const Output = bun.Output;
const Global = bun.Global;
const Environment = bun.Environment;
const strings = bun.strings;
const MutableString = bun.MutableString;
const stringZ = bun.stringZ;
const default_allocator = bun.default_allocator;
const C = bun.C;
const clap = @import("../src/deps/zig-clap/clap.zig");
const URL = @import("../src/url.zig").URL;
const Headers = @import("root").bun.http.Headers;
const Method = @import("../src/http/method.zig").Method;
const ColonListType = @import("../src/cli/colon_list_type.zig").ColonListType;
const HeadersTuple = ColonListType(string, noop_resolver);
const path_handler = @import("../src/resolver/resolve_path.zig");
const NetworkThread = @import("root").bun.http.NetworkThread;
const HTTP = @import("root").bun.http;
fn noop_resolver(in: string) !string {
return in;
}
var waker: bun.Async.Waker = undefined;
fn spamMe(count: usize) void {
Output.Source.configureNamedThread("1");
defer Output.flush();
var timer = std.time.Timer.start() catch unreachable;
var i: usize = 0;
while (i < count) : (i += 1) {
waker.wake() catch unreachable;
}
Output.prettyErrorln("[EVFILT_MACHPORT] Sent {any}", .{bun.fmt.fmtDuration(timer.read())});
}
const thread_count = 1;
pub fn machMain(runs: usize) anyerror!void {
defer Output.flush();
waker = try bun.Async.Waker.init(bun.default_allocator);
var args = try std.process.argsAlloc(bun.default_allocator);
const count = std.fmt.parseInt(usize, args[args.len - 1], 10) catch 1024;
var elapsed: u64 = 0;
var remaining_runs: usize = runs;
while (remaining_runs > 0) : (remaining_runs -= 1) {
var threads: [thread_count]std.Thread = undefined;
var j: usize = 0;
while (j < thread_count) : (j += 1) {
threads[j] = try std.Thread.spawn(.{}, spamMe, .{count});
}
var timer = try std.time.Timer.start();
var i: usize = 0;
while (i < count * thread_count) : (i += 1) {
i += try waker.wait();
}
j = 0;
while (j < thread_count) : (j += 1) {
threads[j].join();
}
elapsed += timer.read();
}
Output.prettyErrorln("[EVFILT_MACHPORT] Recv {any}", .{bun.fmt.fmtDuration(elapsed)});
}
var user_waker: bun.Async.UserFilterWaker = undefined;
fn spamMeUserFilter(count: usize) void {
Output.Source.configureNamedThread("2");
defer Output.flush();
var timer = std.time.Timer.start() catch unreachable;
var i: usize = 0;
while (i < count * thread_count) : (i += 1) {
user_waker.wake() catch unreachable;
}
Output.prettyErrorln("[EVFILT_USER] Sent {any}", .{bun.fmt.fmtDuration(timer.read())});
}
pub fn userMain(runs: usize) anyerror!void {
defer Output.flush();
user_waker = try bun.Async.UserFilterWaker.init(bun.default_allocator);
var args = try std.process.argsAlloc(bun.default_allocator);
const count = std.fmt.parseInt(usize, args[args.len - 1], 10) catch 1024;
var remaining_runs = runs;
var elapsed: u64 = 0;
while (remaining_runs > 0) : (remaining_runs -= 1) {
var threads: [thread_count]std.Thread = undefined;
var j: usize = 0;
while (j < thread_count) : (j += 1) {
threads[j] = try std.Thread.spawn(.{}, spamMeUserFilter, .{count});
}
var timer = try std.time.Timer.start();
var i: usize = 0;
while (i < count) {
i += try user_waker.wait();
}
j = 0;
while (j < thread_count) : (j += 1) {
threads[j].join();
}
elapsed += timer.read();
}
Output.prettyErrorln("[EVFILT_USER] Recv {any}", .{bun.fmt.fmtDuration(elapsed)});
Output.flush();
}
pub fn main() anyerror!void {
var stdout_ = std.io.getStdOut();
var stderr_ = std.io.getStdErr();
var output_source = Output.Source.init(stdout_, stderr_);
Output.Source.set(&output_source);
var args = try std.process.argsAlloc(bun.default_allocator);
const count = std.fmt.parseInt(usize, args[args.len - 1], 10) catch 1024;
Output.prettyErrorln("For {d} messages and {d} threads:", .{ count, thread_count });
Output.flush();
defer Output.flush();
const runs = if (std.os.getenv("RUNS")) |run_count| try std.fmt.parseInt(usize, run_count, 10) else 1;
if (std.os.getenv("NO_MACH") == null)
try machMain(runs);
if (std.os.getenv("NO_USER") == null)
try userMain(runs);
}