Created
January 3, 2020 23:19
-
-
Save kristoff-it/5f0fe16708b74e464c39e6bde4c3664b to your computer and use it in GitHub Desktop.
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 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