Skip to content

Commit

Permalink
[benchmarks] Update latex benchmarker
Browse files Browse the repository at this point in the history
  • Loading branch information
mcopik committed Oct 20, 2024
1 parent 78c238d commit 4ca76ed
Showing 1 changed file with 55 additions and 37 deletions.
92 changes: 55 additions & 37 deletions benchmarks/latex-service/benchmarker_compiling.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,18 +49,22 @@ struct Config {
struct CompileRequest {
std::string file;
bool clean;
bool full_clean;

template <typename Ar>
void save(Ar& archive) const
{
archive(CEREAL_NVP(file));
archive(CEREAL_NVP(clean));
archive(CEREAL_NVP(full_clean));
}

template <typename Ar>
void load(Ar& archive)
{
archive(CEREAL_NVP(file));
archive(CEREAL_NVP(clean));
archive(CEREAL_NVP(full_clean));
}
};

Expand Down Expand Up @@ -114,6 +118,7 @@ struct CompilationResult {
struct Result {
std::string message;


template <typename Ar>
void save(Ar& archive) const
{
Expand Down Expand Up @@ -231,6 +236,7 @@ int main(int argc, char** argv)
);

if (!proc.has_value() || !proc->connect()) {
std::cerr << "Couldn't connect! " << proc.has_value() << std::endl;
abort();
}

Expand All @@ -254,16 +260,21 @@ int main(int argc, char** argv)

auto invoc = proc->invoke("update-file", "invocation-id", data.data(), data.size());
if (invoc.return_code != 0) {
std::cerr << "Failed invocation of upload_file!" << std::endl;
std::cerr << invoc.payload_len << std::endl;
std::cerr << invoc.payload << std::endl;
abort();
}
}

CompileRequest req{"sample-sigconf.tex", true};
CompileRequest req{"sample-sigconf.tex", true, false };
auto data = generate_input_compile(req);
auto begin = std::chrono::high_resolution_clock::now();
auto invoc = proc->invoke("compile", "invocation-id", data.data(), data.size());
auto end = std::chrono::high_resolution_clock::now();
if (invoc.return_code != 0) {
std::cerr << "Failed invocation of compile!" << std::endl;
std::cerr << invoc.payload << std::endl;
abort();
}
auto res = get_output<CompilationResult>(invoc.payload.get(), invoc.payload_len);
Expand All @@ -277,8 +288,39 @@ int main(int argc, char** argv)
}

{
std::ofstream output{fmt::format("output_compiling_1_praas_{}", i)};
output << res.output;
std::ofstream output{fmt::format("output_compiling_1_praas_{}.txt", i)};
//output << res.output;
output << std::string_view{invoc.payload.get(), invoc.payload_len} << std::endl;
}
}

for (int i = 0; i < cfg.repetitions + 1; ++i) {

spdlog::info("Begin rep {}", i);
CompileRequest req{"sample-sigconf", false};
auto data = generate_input_compile(req);
auto begin = std::chrono::high_resolution_clock::now();
auto invoc = proc->invoke("get-pdf", "invocation-id", data.data(), data.size());
auto end = std::chrono::high_resolution_clock::now();
if (invoc.return_code != 0) {
std::cerr << "Failed invocation!" << std::endl;
abort();
}
if(invoc.payload_len == 0) {
std::cerr << "Failed invocation!" << std::endl;
abort();
}
auto res = get_output<ResultPDF>(invoc.payload.get(), invoc.payload_len);

if (i > 0) {
measurements.emplace_back(
"get-pdf", "default", i, data.length(), invoc.payload_len,
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;
}
}

Expand All @@ -297,7 +339,7 @@ int main(int argc, char** argv)
}
}

CompileRequest req{"sample-sigconf.tex", false};
CompileRequest req{"sample-sigconf.tex", false, false};
auto data = generate_input_compile(req);
auto begin = std::chrono::high_resolution_clock::now();
auto invoc = proc->invoke("compile", "invocation-id", data.data(), data.size());
Expand All @@ -315,8 +357,8 @@ int main(int argc, char** argv)
);
}
{
std::ofstream output{fmt::format("output_compiling_2_praas_{}", i)};
output << res.output;
std::ofstream output{fmt::format("output_compiling_2_praas_{}.txt", i)};
output << std::string_view{invoc.payload.get(), invoc.payload_len} << std::endl;
}
}

Expand All @@ -327,22 +369,22 @@ int main(int argc, char** argv)

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

std::string data;
std::string file_data;
for (const auto& file : update_files) {

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

auto invoc = proc->invoke("update-file", "invocation-id", data.data(), data.size());
auto invoc = proc->invoke("update-file", "invocation-id", file_data.data(), file_data.size());
if (invoc.return_code != 0) {
abort();
}
}

CompileRequest req{"sample-sigconf.tex", false};
CompileRequest req{"sample-sigconf.tex", false, true};
auto data = generate_input_compile(req);
auto begin = std::chrono::high_resolution_clock::now();
auto invoc = proc->invoke("compile", "invocation-id", data.data(), data.size());
Expand All @@ -360,35 +402,11 @@ int main(int argc, char** argv)
);
}
{
std::ofstream output{fmt::format("output_compiling_3_praas_{}", i)};
output << res.output;
std::ofstream output{fmt::format("output_compiling_3_praas_{}.txt", i)};
output << std::string_view{invoc.payload.get(), invoc.payload_len} << std::endl;
}
}

for (int i = 0; i < cfg.repetitions + 1; ++i) {

spdlog::info("Begin rep {}", i);
CompileRequest req{"sample-sigconf", false};
auto data = generate_input_compile(req);
auto begin = std::chrono::high_resolution_clock::now();
auto invoc = proc->invoke("get-pdf", "invocation-id", data.data(), data.size());
auto end = std::chrono::high_resolution_clock::now();
if (invoc.return_code != 0) {
abort();
}
auto res = get_output<ResultPDF>(invoc.payload.get(), invoc.payload_len);

if (i > 0) {
measurements.emplace_back(
"get-pdf", "default", i, data.length(), invoc.payload_len,
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

0 comments on commit 4ca76ed

Please sign in to comment.