mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-16 16:56:09 +03:00
simd: minor tweaks
This commit is contained in:
@ -23,8 +23,8 @@ ARGS=""
|
|||||||
|
|
||||||
hyperfine \
|
hyperfine \
|
||||||
--warmup 10 \
|
--warmup 10 \
|
||||||
-n baseline \
|
-n noop \
|
||||||
"./zig-out/bin/bench-codepoint-width --mode=baseline${ARGS} </tmp/ghostty_bench_data" \
|
"./zig-out/bin/bench-codepoint-width --mode=noop${ARGS} </tmp/ghostty_bench_data" \
|
||||||
-n wcwidth \
|
-n wcwidth \
|
||||||
"./zig-out/bin/bench-codepoint-width --mode=wcwidth${ARGS} </tmp/ghostty_bench_data" \
|
"./zig-out/bin/bench-codepoint-width --mode=wcwidth${ARGS} </tmp/ghostty_bench_data" \
|
||||||
-n ziglyph \
|
-n ziglyph \
|
||||||
|
@ -20,7 +20,7 @@ const simd = @import("../simd/main.zig");
|
|||||||
const UTF8Decoder = @import("../terminal/UTF8Decoder.zig");
|
const UTF8Decoder = @import("../terminal/UTF8Decoder.zig");
|
||||||
|
|
||||||
const Args = struct {
|
const Args = struct {
|
||||||
mode: Mode = .baseline,
|
mode: Mode = .noop,
|
||||||
|
|
||||||
/// The size for read buffers. Doesn't usually need to be changed. The
|
/// The size for read buffers. Doesn't usually need to be changed. The
|
||||||
/// main point is to make this runtime known so we can avoid compiler
|
/// main point is to make this runtime known so we can avoid compiler
|
||||||
@ -40,7 +40,7 @@ const Mode = enum {
|
|||||||
/// The baseline mode copies the data from the fd into a buffer. This
|
/// The baseline mode copies the data from the fd into a buffer. This
|
||||||
/// is used to show the minimal overhead of reading the fd into memory
|
/// is used to show the minimal overhead of reading the fd into memory
|
||||||
/// and establishes a baseline for the other modes.
|
/// and establishes a baseline for the other modes.
|
||||||
baseline,
|
noop,
|
||||||
|
|
||||||
/// libc wcwidth
|
/// libc wcwidth
|
||||||
wcwidth,
|
wcwidth,
|
||||||
@ -74,14 +74,14 @@ 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) {
|
||||||
.baseline => try benchBaseline(reader, buf),
|
.noop => try benchNoop(reader, buf),
|
||||||
.wcwidth => try benchWcwidth(reader, buf),
|
.wcwidth => try benchWcwidth(reader, buf),
|
||||||
.ziglyph => try benchZiglyph(reader, buf),
|
.ziglyph => try benchZiglyph(reader, buf),
|
||||||
.simd => try benchSimd(reader, buf),
|
.simd => try benchSimd(reader, buf),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
noinline fn benchBaseline(
|
noinline fn benchNoop(
|
||||||
reader: anytype,
|
reader: anytype,
|
||||||
buf: []u8,
|
buf: []u8,
|
||||||
) !void {
|
) !void {
|
||||||
|
@ -211,11 +211,11 @@ int8_t CodepointWidthImpl(D d, T input) {
|
|||||||
//
|
//
|
||||||
// NOTE: 0x2E3B is technically width 3 but for our terminal we only
|
// NOTE: 0x2E3B is technically width 3 but for our terminal we only
|
||||||
// handle up to width 2 as wide so we will treat it as width 2.
|
// handle up to width 2 as wide so we will treat it as width 2.
|
||||||
HWY_ALIGN T gte_keys[] = {
|
HWY_ALIGN constexpr T gte_keys[] = {
|
||||||
0x2E3A, 0x1f1e6, 0x3400, 0x4E00, 0xF900, 0x20000, 0x30000, 0x2E3B,
|
0x2E3A, 0x1f1e6, 0x3400, 0x4E00, 0xF900, 0x20000, 0x30000, 0x2E3B,
|
||||||
0, 0, 0, 0, 0, 0, 0, 0,
|
0, 0, 0, 0, 0, 0, 0, 0,
|
||||||
};
|
};
|
||||||
HWY_ALIGN T lte_keys[] = {
|
HWY_ALIGN constexpr T lte_keys[] = {
|
||||||
0x2E3A, 0x1f1ff, 0x4DBF, 0x9FFF, 0xFAFF, 0x2FFFD, 0x3FFFD, 0x2E3B,
|
0x2E3A, 0x1f1ff, 0x4DBF, 0x9FFF, 0xFAFF, 0x2FFFD, 0x3FFFD, 0x2E3B,
|
||||||
0, 0, 0, 0, 0, 0, 0, 0,
|
0, 0, 0, 0, 0, 0, 0, 0,
|
||||||
};
|
};
|
||||||
@ -234,10 +234,10 @@ int8_t CodepointWidthImpl(D d, T input) {
|
|||||||
|
|
||||||
{
|
{
|
||||||
// Definitely width 0
|
// Definitely width 0
|
||||||
HWY_ALIGN T gte_keys[] = {
|
HWY_ALIGN constexpr T gte_keys[] = {
|
||||||
0x1160, 0x2060, 0xFFF0, 0xE0000, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
0x1160, 0x2060, 0xFFF0, 0xE0000, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||||
};
|
};
|
||||||
HWY_ALIGN T lte_keys[] = {
|
HWY_ALIGN constexpr T lte_keys[] = {
|
||||||
0x11FF, 0x206F, 0xFFF8, 0xE0FFF, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
0x11FF, 0x206F, 0xFFF8, 0xE0FFF, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||||
};
|
};
|
||||||
size_t i = 0;
|
size_t i = 0;
|
||||||
|
Reference in New Issue
Block a user