mirror of
https://github.com/kasmtech/KasmVNC.git
synced 2025-06-27 21:21:56 +02:00
KASM-6984 Refactor benchmark test case generation logic
This commit is contained in:
parent
de506f00c3
commit
ebce680e79
@ -22,6 +22,7 @@
|
|||||||
#include <rfb/LogWriter.h>
|
#include <rfb/LogWriter.h>
|
||||||
#include <numeric>
|
#include <numeric>
|
||||||
#include <tinyxml2.h>
|
#include <tinyxml2.h>
|
||||||
|
#include <sstream>
|
||||||
|
|
||||||
void benchmark(const std::string &path) {
|
void benchmark(const std::string &path) {
|
||||||
AVFormatContext *format_ctx = nullptr;
|
AVFormatContext *format_ctx = nullptr;
|
||||||
@ -132,12 +133,11 @@ void benchmark(const std::string &path) {
|
|||||||
vlog.info("Frame took %lu ns", duration);
|
vlog.info("Frame took %lu ns", duration);
|
||||||
|
|
||||||
auto [jpeg_stats, webp_stats, bytes, udp_bytes] = connection.getStats();
|
auto [jpeg_stats, webp_stats, bytes, udp_bytes] = connection.getStats();
|
||||||
vlog.info("JPEG stats: %d ms", jpeg_stats.ms);
|
//vlog.info("JPEG stats: %d ms", jpeg_stats.ms);
|
||||||
vlog.info("JPEG stats: %d rects", jpeg_stats.rects);
|
//vlog.info("JPEG stats: %d rects", jpeg_stats.rects);
|
||||||
|
|
||||||
vlog.info("WebP stats: %d ms", webp_stats.ms);
|
|
||||||
vlog.info("WebP stats: %d rects", webp_stats.rects);
|
|
||||||
|
|
||||||
|
//vlog.info("WebP stats: %d ms", webp_stats.ms);
|
||||||
|
// vlog.info("WebP stats: %d rects", webp_stats.rects);
|
||||||
|
|
||||||
timings[frames++] = duration;
|
timings[frames++] = duration;
|
||||||
}
|
}
|
||||||
@ -175,44 +175,31 @@ void benchmark(const std::string &path) {
|
|||||||
|
|
||||||
doc.InsertFirstChild(test_suit);
|
doc.InsertFirstChild(test_suit);
|
||||||
|
|
||||||
|
constexpr auto div = 1. / (1000 * 1000);
|
||||||
|
auto total_tests{0};
|
||||||
|
|
||||||
|
auto add_benchmark_item = [&doc, &test_suit, &total_tests](const char *name, auto value) {
|
||||||
auto *test_case = doc.NewElement("testcase");
|
auto *test_case = doc.NewElement("testcase");
|
||||||
test_case->SetAttribute("name", "Average time encoding frame, ms");
|
test_case->SetAttribute("name", name);
|
||||||
test_case->SetAttribute("time", average / 1000);
|
test_case->SetAttribute("time", value);
|
||||||
test_case->SetAttribute("runs", 1);
|
test_case->SetAttribute("runs", 1);
|
||||||
test_case->SetAttribute("classname", "KasmVNC");
|
test_case->SetAttribute("classname", "KasmVNC");
|
||||||
test_suit->InsertEndChild(test_case);
|
test_suit->InsertEndChild(test_case);
|
||||||
|
|
||||||
test_case = doc.NewElement("testcase");
|
++total_tests;
|
||||||
test_case->SetAttribute("name", "Median time encoding frame, ms");
|
};
|
||||||
test_case->SetAttribute("time", average / 1000);
|
|
||||||
test_case->SetAttribute("runs", 1);
|
|
||||||
test_case->SetAttribute("classname", "KasmVNC");
|
|
||||||
test_suit->InsertEndChild(test_case);
|
|
||||||
|
|
||||||
test_case = doc.NewElement("testcase");
|
add_benchmark_item("Average time encoding frame, ms", average * div);
|
||||||
test_case->SetAttribute("name", "Total time encoding, ms");
|
add_benchmark_item("Median time encoding frame, ms", median * div);
|
||||||
test_case->SetAttribute("time", sum);
|
add_benchmark_item("Total time encoding, ms", sum * div);
|
||||||
test_case->SetAttribute("runs", 1);
|
|
||||||
test_case->SetAttribute("classname", "KasmVNC");
|
|
||||||
test_suit->InsertEndChild(test_case);
|
|
||||||
|
|
||||||
test_case = doc.NewElement("testcase");
|
std::stringstream ss;
|
||||||
test_case->SetAttribute("name", "KBytes sent");
|
ss << "KBytes sent: " << bytes / 1024;
|
||||||
test_case->SetAttribute("time", bytes / 1024);
|
add_benchmark_item(ss.str().c_str(), 0);
|
||||||
test_case->SetAttribute("runs", 1);
|
|
||||||
test_case->SetAttribute("classname", "KasmVNC");
|
|
||||||
test_suit->InsertEndChild(test_case);
|
|
||||||
|
|
||||||
test_case = doc.NewElement("testcase");
|
//ss.flush();
|
||||||
test_case->SetAttribute("name", "KBytes sent (UDP)");
|
//ss << "KBytes sent (UDP): " << udp_bytes / 1024;
|
||||||
test_case->SetAttribute("time", udp_bytes / 1024);
|
//add_benchmark_item(ss.str().c_str(), 0);
|
||||||
test_case->SetAttribute("runs", 1);
|
|
||||||
test_case->SetAttribute("classname", "KasmVNC");
|
|
||||||
test_suit->InsertEndChild(test_case);
|
|
||||||
|
|
||||||
test_suit->SetAttribute("tests", 5);
|
|
||||||
test_suit->SetAttribute("failures", 0);
|
|
||||||
//test_suit->SetAttribute("time", total_time);
|
|
||||||
|
|
||||||
doc.SaveFile("Benchmark.xml");
|
doc.SaveFile("Benchmark.xml");
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user