Obsolete
/
libipc-old
Archived
3
0
Fork 0
This repository has been archived on 2024-06-18. You can view files and clone it, but cannot push or open issues/pull-requests.
libipc-old/zig-impl/misc/misc-test.zig

45 lines
978 B
Zig
Raw Normal View History

2022-12-24 18:57:51 +01:00
const std = @import("std");
const hexdump = @import("./hexdump.zig");
const testing = std.testing;
const net = std.net;
const fmt = std.fmt;
2022-12-24 23:09:25 +01:00
const Timer = std.time.Timer;
2022-12-24 18:57:51 +01:00
const print = std.debug.print;
const P = std.ArrayList(std.os.pollfd);
2022-12-24 23:09:25 +01:00
fn arraylist_test() !void {
2022-12-24 18:57:51 +01:00
const config = .{.safety = true};
var gpa = std.heap.GeneralPurposeAllocator(config){};
defer _ = gpa.deinit();
const allocator = gpa.allocator();
var p = P.init(allocator);
defer p.deinit();
try p.append(.{.fd = 8, .events = 0, .revents = 0});
for(p.items) |i| { print("fd: {}\n", .{i.fd}); }
}
2022-12-24 23:09:25 +01:00
fn timer_test() !void {
var timer = try Timer.start();
var count: u64 = 0;
while (count < 100000) {
count += 1;
print("\rcount = {}", .{count});
}
print("\n", .{});
var duration = timer.read();
print("took {} us\n", .{duration / 1000});
}
2022-12-24 18:57:51 +01:00
pub fn main() !u8 {
2022-12-24 23:09:25 +01:00
// try arraylist_test();
try timer_test();
2022-12-24 18:57:51 +01:00
return 0;
}