Skip to content

Commit

Permalink
[benchmarks] Update LaTeX benchmarkers
Browse files Browse the repository at this point in the history
  • Loading branch information
mcopik committed Oct 20, 2024
1 parent a33b92d commit 78c238d
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 10 deletions.
37 changes: 32 additions & 5 deletions benchmarks/latex-service/benchmarker_compiling.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,9 @@ std::string generate_input_json(File& file)
{
cereal::JSONOutputArchive archive_out{output};
file.save(archive_out);
assert(stream.good());
if(!output.good()) {
abort();
}
}
return output.str();
}
Expand All @@ -163,7 +165,9 @@ std::string generate_input_compile(CompileRequest& req)
{
cereal::JSONOutputArchive archive_out{output};
req.save(archive_out);
assert(stream.good());
if(!output.good()) {
abort();
}
}
return output.str();
}
Expand Down Expand Up @@ -271,10 +275,15 @@ int main(int argc, char** argv)
res.time_compile
);
}

{
std::ofstream output{fmt::format("output_compiling_1_praas_{}", i)};
output << res.output;
}
}

std::vector<std::string> update_files{"secs/acks.tex"};
// Scenario 1 - small update
// Scenario 1 - small update, no recompilation
for (int i = 0; i < cfg.repetitions + 1; ++i) {

spdlog::info("Begin rep {}", i);
Expand Down Expand Up @@ -305,17 +314,27 @@ int main(int argc, char** argv)
res.time_compile
);
}
{
std::ofstream output{fmt::format("output_compiling_2_praas_{}", i)};
output << res.output;
}
}

update_files = {
"acmart.cls", "sampleteaser.pdf", "secs/core.tex", "secs/figure.tex", "secs/multi.tex"};
// Scenario 1 - large update
// Scenario 1 - large update that leads to a failure.
for (int i = 0; i < cfg.repetitions + 1; ++i) {

spdlog::info("Begin rep {}", i);

std::string data;
for (const auto& file : update_files) {
auto data = upload_file(file, cfg, false);

if(file == "acmart.cls") {
data = upload_file(file, cfg, false);
} else {
data = upload_file(file, cfg, true);
}

auto invoc = proc->invoke("update-file", "invocation-id", data.data(), data.size());
if (invoc.return_code != 0) {
Expand All @@ -340,6 +359,10 @@ int main(int argc, char** argv)
res.time_compile
);
}
{
std::ofstream output{fmt::format("output_compiling_3_praas_{}", i)};
output << res.output;
}
}

for (int i = 0; i < cfg.repetitions + 1; ++i) {
Expand All @@ -361,6 +384,10 @@ int main(int argc, char** argv)
std::chrono::duration_cast<std::chrono::nanoseconds>(end - begin).count(), 0, 0
);
}
{
std::ofstream output{fmt::format("output_get_pdf_praas_{}", i)};
output << res.data;
}
}

std::cerr << measurements.size() << std::endl;
Expand Down
8 changes: 6 additions & 2 deletions benchmarks/latex-service/benchmarker_compiling_s3.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,9 @@ std::string generate_input_json(File& file)
{
cereal::JSONOutputArchive archive_out{output};
file.save(archive_out);
assert(stream.good());
if(!output.good()) {
abort();
}
}
return output.str();
}
Expand All @@ -165,7 +167,9 @@ std::string generate_input_compile(CompileRequest& req)
{
cereal::JSONOutputArchive archive_out{output};
req.save(archive_out);
assert(stream.good());
if(!output.good()) {
abort();
}
}
return output.str();
}
Expand Down
24 changes: 22 additions & 2 deletions benchmarks/latex-service/benchmarker_editing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,9 @@ std::string generate_input_json(File& file)
{
cereal::JSONOutputArchive archive_out{output};
file.save(archive_out);
assert(stream.good());
if(!output.good()) {
abort();
}
}
return output.str();
}
Expand Down Expand Up @@ -125,6 +127,7 @@ int main(int argc, char** argv)

std::vector<std::tuple<std::string, std::string, int, int, int, long>> measurements;

int j = 0;
for (std::string file : cfg.input_files) {

spdlog::info("Begin file {}", file);
Expand All @@ -134,6 +137,10 @@ int main(int argc, char** argv)
input_file.path = std::filesystem::path{file}.parent_path();

std::ifstream input{std::filesystem::path{cfg.inputs_directory} / file};
if(input.fail()) {
spdlog::error("Failed to open the file!");
abort();
}
std::stringstream buffer;
buffer << input.rdbuf();
input_file.data = buffer.str();
Expand All @@ -158,9 +165,16 @@ int main(int argc, char** argv)
std::chrono::duration_cast<std::chrono::nanoseconds>(end - begin).count()
);
}
{
std::ofstream output{fmt::format("output_update_file_{}_praas_{}", j, i)};
output << invoc.payload;
}
}

++j;
}

j = 0;
for (std::string file : cfg.input_files) {

spdlog::info("Begin file {}", file);
Expand All @@ -186,9 +200,15 @@ int main(int argc, char** argv)
std::chrono::duration_cast<std::chrono::nanoseconds>(end - begin).count()
);
}
{
std::ofstream output{fmt::format("output_get_file_{}_praas_{}", j, i)};
output << invoc.payload;
}
}

++j;
}
std::cerr << measurements.size() << std::endl;
//std::cerr << measurements.size() << std::endl;

std::ofstream out_file{cfg.output_file, std::ios::out};
out_file << "type,input,repetition,input-size,output-size,time" << '\n';
Expand Down
4 changes: 3 additions & 1 deletion benchmarks/latex-service/benchmarker_editing_s3.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,9 @@ std::string generate_input_json(File& file)
{
cereal::JSONOutputArchive archive_out{output};
file.save(archive_out);
assert(stream.good());
if(!output.good()) {
abort();
}
}
return output.str();
}
Expand Down

0 comments on commit 78c238d

Please sign in to comment.