mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-16 16:56:09 +03:00
bench/stream: add utf8
This commit is contained in:
7
bench.sh
7
bench.sh
@ -3,6 +3,7 @@
|
|||||||
# TODO: This script is temporary, remove it from the repo
|
# TODO: This script is temporary, remove it from the repo
|
||||||
|
|
||||||
|
|
||||||
|
DATA="ascii"
|
||||||
SIZE="25M"
|
SIZE="25M"
|
||||||
|
|
||||||
# Uncomment to test with an active terminal state.
|
# Uncomment to test with an active terminal state.
|
||||||
@ -11,8 +12,8 @@ SIZE="25M"
|
|||||||
hyperfine \
|
hyperfine \
|
||||||
--warmup 10 \
|
--warmup 10 \
|
||||||
-n memcpy \
|
-n memcpy \
|
||||||
"./zig-out/bin/bench-stream --mode=gen-ascii | head -c ${SIZE} | ./zig-out/bin/bench-stream --mode=noop${ARGS}" \
|
"./zig-out/bin/bench-stream --mode=gen-${DATA} | head -c ${SIZE} | ./zig-out/bin/bench-stream --mode=noop${ARGS}" \
|
||||||
-n scalar \
|
-n scalar \
|
||||||
"./zig-out/bin/bench-stream --mode=gen-ascii | head -c ${SIZE} | ./zig-out/bin/bench-stream --mode=scalar${ARGS}" \
|
"./zig-out/bin/bench-stream --mode=gen-${DATA} | head -c ${SIZE} | ./zig-out/bin/bench-stream --mode=scalar${ARGS}" \
|
||||||
-n simd \
|
-n simd \
|
||||||
"./zig-out/bin/bench-stream --mode=gen-ascii | head -c ${SIZE} | ./zig-out/bin/bench-stream --mode=simd${ARGS}"
|
"./zig-out/bin/bench-stream --mode=gen-${DATA} | head -c ${SIZE} | ./zig-out/bin/bench-stream --mode=simd${ARGS}"
|
||||||
|
@ -12,6 +12,7 @@ const std = @import("std");
|
|||||||
const assert = std.debug.assert;
|
const assert = std.debug.assert;
|
||||||
const Allocator = std.mem.Allocator;
|
const Allocator = std.mem.Allocator;
|
||||||
const ArenaAllocator = std.heap.ArenaAllocator;
|
const ArenaAllocator = std.heap.ArenaAllocator;
|
||||||
|
const ziglyph = @import("ziglyph");
|
||||||
const cli = @import("../cli.zig");
|
const cli = @import("../cli.zig");
|
||||||
const terminal = @import("../terminal/main.zig");
|
const terminal = @import("../terminal/main.zig");
|
||||||
|
|
||||||
@ -57,6 +58,11 @@ const Mode = enum {
|
|||||||
|
|
||||||
// Generate an infinite stream of random printable ASCII characters.
|
// Generate an infinite stream of random printable ASCII characters.
|
||||||
@"gen-ascii",
|
@"gen-ascii",
|
||||||
|
|
||||||
|
// Generate an infinite stream of repeated UTF-8 characters. We don't
|
||||||
|
// currently do random generation because trivial implementations are
|
||||||
|
// too slow and I'm a simple man.
|
||||||
|
@"gen-utf8",
|
||||||
};
|
};
|
||||||
|
|
||||||
pub const std_options = struct {
|
pub const std_options = struct {
|
||||||
@ -83,6 +89,7 @@ pub fn main() !void {
|
|||||||
// Handle the modes that do not depend on terminal state first.
|
// Handle the modes that do not depend on terminal state first.
|
||||||
switch (args.mode) {
|
switch (args.mode) {
|
||||||
.@"gen-ascii" => try genAscii(writer),
|
.@"gen-ascii" => try genAscii(writer),
|
||||||
|
.@"gen-utf8" => try genUtf8(writer),
|
||||||
.noop => try benchNoop(reader, buf),
|
.noop => try benchNoop(reader, buf),
|
||||||
|
|
||||||
// Handle the ones that depend on terminal state next
|
// Handle the ones that depend on terminal state next
|
||||||
@ -140,6 +147,15 @@ fn genData(writer: anytype, alphabet: []const u8) !void {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn genUtf8(writer: anytype) !void {
|
||||||
|
while (true) {
|
||||||
|
writer.writeAll(random_utf8) catch |err| switch (err) {
|
||||||
|
error.BrokenPipe => return, // stdout closed
|
||||||
|
else => return err,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
noinline fn benchNoop(reader: anytype, buf: []u8) !void {
|
noinline fn benchNoop(reader: anytype, buf: []u8) !void {
|
||||||
var total: usize = 0;
|
var total: usize = 0;
|
||||||
while (true) {
|
while (true) {
|
||||||
@ -192,3 +208,5 @@ const TerminalHandler = struct {
|
|||||||
try self.t.print(cp);
|
try self.t.print(cp);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const random_utf8 = "⨴⭬∎⯀Ⳟ⳨⍈♍⒄⣹⇚ⱎ⯡⯴↩ⵆ⼳ⶦ⦥➍Ⲡ⽉❞⹀⢧€⣁ⶐ⸲⣷⏝⣶⫿▝⨽⬃ↁ↵⯙ⶵ╡∾⭡′⫼↼┫⮡ↅ⍞‡▱⺁⿒⽛⎭☜Ⱝ⣘✬⢟⁴⟹⪝ℌ❓␆╣┳⽑⺄✽ⳗⵍ⦵ⱍ⭑⛒ⅉ⛠➌₯ⵔⷋ❷ⱳ⣖⭐⮋ₒ⥚ⷃ╶⌈⸣❥⦿⪶₮╋⅌ⳬⴛ⥚♇╬❜⺷⡬⏠⧥┺❼⏲Ⓙ⽕╶⾉⺪⁑⎕⅕⼧⊀ⲡ⊺⪭⟾Ⅵ⍌⛄⠻⣻₮ⰹⴺ⪂∖⊹⤔⦒⽳⫄⍮↷⣌⩐⨼⯂◺⍙⭺⟂⎯ⱼ⫺∌⡉ⳅ⛲⡏⃘⺃ⴜ⾩⭦ⷭ⨟☌⍃⧪⮧ⓛ♮ⲓ∘⣝⤐⎭ⷺⰫⶔ☎⾨⾐≦␢⋔⢟ⶐ⏁⚄⦡⾞✊⾾⫿⪨⮰ⓙ⌽⭲⫬⒈⊻⸣⌳⋡ⱄⲛ⓬➼⌧⟮⹖♞ℚⷱ⭥⚣⏳⟾❠☏⦻⑽−∪ⅆ☁⿑⦣Ⱳ⺧⺊Ⓞ⫽⦀⃐⚽⎌⥰⚪⢌⛗⸋⛂⾽Ⰳ⍧⛗◁❠↺≍‸ⴣ⭰‾⡸⩛⭷ⵒ⚉❚⨳⑫∇┬⚌⨙╘ℹ⢱⏴∸⾀⌟⡄⺣⦦ⱏ⼚⿇├⌮⸿⯔₮—⥟╖◡ⶕ┧⒞⏖⏧⟀❲➚➳Ⰼ┸⬖⸓⁃⹚⫣┭↜〈☶≍☨╟⿹ⳙ⺽⸡⛞⚟⯓⥟┞⿄⃫⭒⠤ⓣ⬱⓼ⱒ⥖✜⛘⠶ⰽ⿉⾣➌⣋⚨⒯◱⢃◔ⱕ⫡⓱⅌Ⱨ⧵⯾┰ⱌ⼳♠⨽⪢⸳⠹⩡Ⓨ⡪⭞⼰⡧ⓖ⤘⽶ⴺ ⨨▅⏟⊕ⴡⴰ␌⚯⦀⫭⨔⬯⨢ⱽ⟓⥫⑤⊘⟧❐▜℅⋣⚏⇭⽁⪂ⲡ⯊⦥⭳⠾⠮℞⒡Ⰼ⦈⭅≉⋆☈▓⺑⡻▷Ⱑ⋖⬜┃ⵍ←⣢ↁ☚⟴⦡⨍⼡◝⯤❓◢⌡⏿⭲✏⎑⧊⼤⪠⋂⚜┯▤⟾⬬Ⓜ⨸⥪ⱘ⒖⋐⡈⏌∠⏁⓳Ⲟ⦽⢯┏Ⲹ⍰ⅹ⚏⍐⟍⣩␖⛂∜❆⤗⒨⓽";
|
||||||
|
Reference in New Issue
Block a user