This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const std = @import("std"); | |
const iterations_per_byte = 1000; | |
const warmup_iterations = 10; | |
pub fn main() !void { | |
// Pin the process to a single core (1) | |
const cpu0001: std.os.linux.cpu_set_t = [1]usize{0b0001} ++ ([_]usize{0} ** (16 - 1)); | |
try std.os.linux.sched_setaffinity(0, &cpu0001); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// https://github.com/crossbeam-rs/crossbeam/blob/abf24e1f31a76ef2590688d0c2bb55f82c7410a9/crossbeam-queue/src/seg_queue.rs | |
const std = @import("std"); | |
const Atomic = std.atomic.Value; | |
const Allocator = std.mem.Allocator; | |
pub fn Channel(T: type) type { | |
return struct { | |
head: Position, | |
tail: Position, | |
allocator: Allocator, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// https://github.com/facebook/folly/blob/1c8bc50e88804e2a7361a57cd9b551dd10f6c5fd/folly/memcpy.S | |
export fn memcpy(maybe_dest: ?[*]u8, maybe_src: ?[*]const u8, len: usize) callconv(.C) ?[*]u8 { | |
if (len == 0) { | |
@branchHint(.unlikely); | |
return maybe_dest; | |
} | |
const dest = maybe_dest.?; | |
const src = maybe_src.?; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import matplotlib.pyplot as plt | |
import matplotlib.ticker as tkr | |
import pandas as pd | |
def sizeof_fmt(x, pos): | |
if x<0: | |
return "" | |
for x_unit in ['bytes', 'kB', 'MB', 'GB', 'TB']: | |
if x < 1024: | |
return "%3.0f %s" % (x, x_unit) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
import argparse | |
import tempfile | |
import subprocess | |
import os | |
import sys | |
from multiprocessing import Pool | |
SKIP_LINE = 'if (builtin.zig_backend == .stage2_riscv64) return error.SkipZigTest;' | |
COMMENT = ' // generated by update.py' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// zig build-exe benchmark.zig -OReleaseFast -lc | |
// ./benchmark 4096 | |
const std = @import("std"); | |
const allocator = std.heap.c_allocator; | |
const iterations_per_byte = 1000; | |
const warmup_iterations = 10; | |
comptime { |