-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
in an attempt to verify benchmarks, the new cpp and zig files now loop over statuses in twitter.json and check that there are exactly 100. running bench/twitter/run.sh * builds zig-out/bin/twitterbench * fetches simdjson.cpp/.h and twitter.json * builds bench/twitter/simdjzon-twitterbench * benchmarks them w/ poop
- Loading branch information
1 parent
174b7f1
commit aeab8cd
Showing
5 changed files
with
98 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
simdjson-bench | ||
simdjson.cpp | ||
simdjson.h | ||
twitter.json |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#include "simdjson.h" | ||
using namespace simdjson; | ||
int main(int argc, char** argv) { | ||
if(argc != 2) { | ||
std::cout << "USAGE: ./simdjson <file.json>" << std::endl; | ||
exit(1); | ||
} | ||
dom::parser parser; | ||
try | ||
{ | ||
const dom::element doc = parser.load(argv[1]); | ||
int i = 0; | ||
for(auto status: doc["statuses"]) { | ||
// std::cout << status["id"] << '\n'; | ||
i += 1; | ||
} | ||
if(i != 100) { | ||
std::cout << "error. expected i=100. found i=" << i << '\n'; | ||
return 1; | ||
} | ||
} | ||
catch(const std::exception& e) | ||
{ | ||
std::cerr << e.what() << '\n'; | ||
return 1; | ||
} | ||
return 0; | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
const std = @import("std"); | ||
const dom = @import("simdjzon").dom; | ||
|
||
pub fn main() !u8 { | ||
var arena = std.heap.ArenaAllocator.init(std.heap.page_allocator); | ||
defer arena.deinit(); | ||
const allocator = arena.allocator(); | ||
const args = try std.process.argsAlloc(allocator); | ||
if(args.len != 2) { | ||
std.debug.print("USAGE: ./simdjson <file.json>\n", .{}); | ||
} | ||
var parser = try dom.Parser.initFile(allocator, args[1], .{}); | ||
defer parser.deinit(); | ||
parser.parse() catch |err| { | ||
std.log.err("parse failed. {s}", .{@errorName(err)}); | ||
return 1; | ||
}; | ||
const statuses = try parser.element().at_pointer("/statuses"); | ||
const array = try statuses.get_array(); | ||
var i: usize = 0; | ||
while(array.at(i)) |status| : (i += 1) { | ||
_ = status; // autofix | ||
// const id = try status.at_pointer("/id"); | ||
// std.debug.print("{}\n", .{try id.get_int64()}); | ||
} | ||
// std.debug.print("i={}\n", .{i}); | ||
if (i != 100) { | ||
std.debug.print("error. expected i=100. found i={}\n", .{i}); | ||
return 1; | ||
} | ||
|
||
return 0; | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#!/bin/bash | ||
set -xe | ||
|
||
rm -f simdjson.cpp simdjson.h twitter.json simdjson-twitterbench | ||
|
||
# build simdjzon | ||
zig version | ||
zig build -Doptimize=ReleaseFast | ||
|
||
# build simdjson | ||
g++ --version | ||
cat bench/twitter/main.cpp | ||
wget https://github.com/simdjson/simdjson/raw/master/singleheader/simdjson.cpp -O bench/twitter/simdjson.cpp | ||
wget https://github.com/simdjson/simdjson/raw/master/singleheader/simdjson.h -O bench/twitter/simdjson.h | ||
wget https://github.com/simdjson/simdjson/raw/master/jsonexamples/twitter.json -O bench/twitter/twitter.json | ||
g++ bench/twitter/main.cpp bench/twitter/simdjson.cpp -Ibench/twitter -o bench/twitter/simdjson-twitterbench -O3 -march=native | ||
|
||
# bench | ||
poop "./bench/twitter/simdjson-twitterbench bench/twitter/twitter.json" "zig-out/bin/twitterbench bench/twitter/twitter.json" |
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