switch to f64 for numbers (matches json)
That change improves performance. Before:
Benchmark 1: /home/lobo/shared/srf/zig-out/bin/srf srf <.zig-cache/o/51f43613e6e43ed5/test-srf-compact.srf
Time (mean ± σ): 113.8 ms ± 3.8 ms [User: 61.2 ms, System: 52.5 ms]
Range (min … max): 109.4 ms … 128.5 ms 26 runs
Benchmark 2: /home/lobo/shared/srf/zig-out/bin/srf srf <.zig-cache/o/c105a3d3b0472f2e/test-srf-long.srf
Time (mean ± σ): 115.5 ms ± 4.0 ms [User: 59.1 ms, System: 56.3 ms]
Range (min … max): 110.8 ms … 127.1 ms 26 runs
Benchmark 3: /home/lobo/shared/srf/zig-out/bin/srf json <.zig-cache/o/cb2a4e8b89e72422/test-json.json
Time (mean ± σ): 131.5 ms ± 3.1 ms [User: 83.2 ms, System: 48.3 ms]
Range (min … max): 127.7 ms … 138.0 ms 23 runs
Summary
/home/lobo/shared/srf/zig-out/bin/srf srf <.zig-cache/o/51f43613e6e43ed5/test-srf-compact.srf ran
1.01 ± 0.05 times faster than /home/lobo/shared/srf/zig-out/bin/srf srf <.zig-cache/o/c105a3d3b0472f2e/test-srf-long.srf
1.16 ± 0.05 times faster than /home/lobo/shared/srf/zig-out/bin/srf json <.zig-cache/o/cb2a4e8b89e72422/test-json.json
After:
Benchmark 1: /home/lobo/shared/srf/zig-out/bin/srf srf <.zig-cache/o/51f43613e6e43ed5/test-srf-compact.srf
Time (mean ± σ): 98.9 ms ± 2.8 ms [User: 51.3 ms, System: 47.7 ms]
Range (min … max): 95.4 ms … 106.6 ms 29 runs
Benchmark 2: /home/lobo/shared/srf/zig-out/bin/srf srf <.zig-cache/o/c105a3d3b0472f2e/test-srf-long.srf
Time (mean ± σ): 103.1 ms ± 3.4 ms [User: 53.8 ms, System: 49.4 ms]
Range (min … max): 99.0 ms … 112.8 ms 28 runs
Benchmark 3: /home/lobo/shared/srf/zig-out/bin/srf json <.zig-cache/o/cb2a4e8b89e72422/test-json.json
Time (mean ± σ): 122.6 ms ± 4.4 ms [User: 75.1 ms, System: 47.6 ms]
Range (min … max): 117.7 ms … 130.7 ms 22 runs
Summary
/home/lobo/shared/srf/zig-out/bin/srf srf <.zig-cache/o/51f43613e6e43ed5/test-srf-compact.srf ran
1.04 ± 0.04 times faster than /home/lobo/shared/srf/zig-out/bin/srf srf <.zig-cache/o/c105a3d3b0472f2e/test-srf-long.srf
1.24 ± 0.06 times faster than /home/lobo/shared/srf/zig-out/bin/srf json <.zig-cache/o/cb2a4e8b89e72422/test-json.json
This commit is contained in:
parent
0aacc8b37b
commit
b37fb7fb1a
1 changed files with 4 additions and 4 deletions
|
|
@ -44,7 +44,7 @@ const ItemValueWithMetaData = struct {
|
||||||
reader_advanced: bool = false,
|
reader_advanced: bool = false,
|
||||||
};
|
};
|
||||||
pub const ItemValue = union(enum) {
|
pub const ItemValue = union(enum) {
|
||||||
number: f128,
|
number: f64,
|
||||||
|
|
||||||
/// Bytes are converted to/from base64, string is not
|
/// Bytes are converted to/from base64, string is not
|
||||||
bytes: []const u8,
|
bytes: []const u8,
|
||||||
|
|
@ -574,7 +574,7 @@ test "long format from README - generic data structures" {
|
||||||
try std.testing.expectEqualStrings("key", first.items[0].key);
|
try std.testing.expectEqualStrings("key", first.items[0].key);
|
||||||
try std.testing.expectEqualStrings("string value, with any data except a \\n. an optional string length between the colons", first.items[0].value.?.string);
|
try std.testing.expectEqualStrings("string value, with any data except a \\n. an optional string length between the colons", first.items[0].value.?.string);
|
||||||
try std.testing.expectEqualStrings("this is a number", first.items[1].key);
|
try std.testing.expectEqualStrings("this is a number", first.items[1].key);
|
||||||
try std.testing.expectEqual(@as(f128, 5), first.items[1].value.?.number);
|
try std.testing.expectEqual(@as(f64, 5), first.items[1].value.?.number);
|
||||||
try std.testing.expectEqualStrings("null value", first.items[2].key);
|
try std.testing.expectEqualStrings("null value", first.items[2].key);
|
||||||
try std.testing.expect(first.items[2].value == null);
|
try std.testing.expect(first.items[2].value == null);
|
||||||
try std.testing.expectEqualStrings("array", first.items[3].key);
|
try std.testing.expectEqualStrings("array", first.items[3].key);
|
||||||
|
|
@ -589,7 +589,7 @@ test "long format from README - generic data structures" {
|
||||||
try std.testing.expectEqualStrings("key", second.items[0].key);
|
try std.testing.expectEqualStrings("key", second.items[0].key);
|
||||||
try std.testing.expectEqualStrings("this is the second record", second.items[0].value.?.string);
|
try std.testing.expectEqualStrings("this is the second record", second.items[0].value.?.string);
|
||||||
try std.testing.expectEqualStrings("this is a number", second.items[1].key);
|
try std.testing.expectEqualStrings("this is a number", second.items[1].key);
|
||||||
try std.testing.expectEqual(@as(f128, 42), second.items[1].value.?.number);
|
try std.testing.expectEqual(@as(f64, 42), second.items[1].value.?.number);
|
||||||
try std.testing.expectEqualStrings("null value", second.items[2].key);
|
try std.testing.expectEqualStrings("null value", second.items[2].key);
|
||||||
try std.testing.expect(second.items[2].value == null);
|
try std.testing.expect(second.items[2].value == null);
|
||||||
try std.testing.expectEqualStrings("array", second.items[3].key);
|
try std.testing.expectEqualStrings("array", second.items[3].key);
|
||||||
|
|
@ -617,7 +617,7 @@ test "compact format from README - generic data structures" {
|
||||||
try std.testing.expectEqualStrings("key", first.items[0].key);
|
try std.testing.expectEqualStrings("key", first.items[0].key);
|
||||||
try std.testing.expectEqualStrings("string value must have a length between colons or end with a comma", first.items[0].value.?.string);
|
try std.testing.expectEqualStrings("string value must have a length between colons or end with a comma", first.items[0].value.?.string);
|
||||||
try std.testing.expectEqualStrings("this is a number", first.items[1].key);
|
try std.testing.expectEqualStrings("this is a number", first.items[1].key);
|
||||||
try std.testing.expectEqual(@as(f128, 5), first.items[1].value.?.number);
|
try std.testing.expectEqual(@as(f64, 5), first.items[1].value.?.number);
|
||||||
try std.testing.expectEqualStrings("null value", first.items[2].key);
|
try std.testing.expectEqualStrings("null value", first.items[2].key);
|
||||||
try std.testing.expect(first.items[2].value == null);
|
try std.testing.expect(first.items[2].value == null);
|
||||||
try std.testing.expectEqualStrings("array", first.items[3].key);
|
try std.testing.expectEqualStrings("array", first.items[3].key);
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue