"git@developer.sourcefind.cn:OpenDAS/torchaudio.git" did not exist on "99ed7183df3df8278cc46de432c31b254e31573e"
Commit a5b72f7a authored by Scott Wolchok's avatar Scott Wolchok Committed by Jesse Beder
Browse files

read benchmark: accept a filename as an argument

On my Macbook Pro, reading from standard input incurs a bunch of locking
overhead, which complicates profiling and (IMO) adds noise to
results. This adds the option to read from a file, which doesn't incur
this overhead.
parent dfbb3884
#include <fstream>
#include <iostream> #include <iostream>
#include "yaml-cpp/emitterstyle.h" #include "yaml-cpp/emitterstyle.h"
...@@ -25,9 +26,19 @@ class NullEventHandler : public YAML::EventHandler { ...@@ -25,9 +26,19 @@ class NullEventHandler : public YAML::EventHandler {
virtual void OnMapEnd() {} virtual void OnMapEnd() {}
}; };
int main() { void run(YAML::Parser& parser) {
YAML::Parser parser(std::cin);
NullEventHandler handler; NullEventHandler handler;
parser.HandleNextDocument(handler); parser.HandleNextDocument(handler);
}
int main(int argc, char** argv) {
if (argc > 1) {
std::ifstream in(argv[1]);
YAML::Parser parser(in);
run(parser);
} else {
YAML::Parser parser(std::cin);
run(parser);
}
return 0; return 0;
} }
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment