Skip to content

Instantly share code, notes, and snippets.

@kristoff-it
Created January 3, 2020 23:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kristoff-it/5f0fe16708b74e464c39e6bde4c3664b to your computer and use it in GitHub Desktop.
Save kristoff-it/5f0fe16708b74e464c39e6bde4c3664b to your computer and use it in GitHub Desktop.
const std = @import("std");
const time = std.time;
const builtin = @import("builtin");
const heyredis = @import("./src/okredis.zig");
pub const io_mode = .evented;
const addr = "127.0.0.1";
pub fn main() !void {
var client: heyredis.Client = undefined;
try heyredis.Client.initIp4(&client, addr, 6379);
defer client.close();
// Test 1
{
try client.send(void, .{ "SET", "counter", "-1" });
var t = try time.Timer.start();
var i: usize = 0;
const loops: usize = 1000;
while (i < loops) : (i += 1) {
const ctr = try client.send(usize, .{ "INCR", "counter" });
if (ctr != i) @panic("Error!");
}
var took = t.read();
std.debug.warn("Counter test -- OK [{d}ms]\n\n", .{@intToFloat(f64, took) / time.millisecond});
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment