normal, save, load

This commit is contained in:
Symious 2025-03-08 20:27:48 +08:00
parent 4f325a2fd3
commit 55f6518fc9
2 changed files with 19 additions and 9 deletions

View File

@ -11,6 +11,7 @@
#include <optional>
#include <random>
#include <vector>
#include <fstream>
#include "common/logging/LogInit.h"
#include "common/net/ib/IBDevice.h"
@ -398,12 +399,21 @@ class StorageBench : public test::UnitTestFabric {
if (!boost::filesystem::exists(outFilePath) || boost::filesystem::is_empty(outFilePath)) {
XLOGF(INFO, "Create a file for perfermance stats at {}", outFilePath);
boost::filesystem::save_string_file(
outFilePath,
"test name,#storages,#chains,#replicas,concurrency,batch size,"
"io size (bytes),effective batch size (batch size / #replicas),elapsed time (us),"
"QPS,IOPS,bandwidth (MB/s),latency samples,min latency (us),max latency (us),avg latency (us),"
"latency P50 (us),latency P75 (us),latency P90 (us),latency P95 (us),latency P99 (us)\n");
std::ofstream outFile(outFilePath);
if (!outFile) {
throw std::runtime_error("Failed to open file: " + outFilePath.string());
}
outFile << "test name,#storages,#chains,#replicas,concurrency,batch size,"
"io size (bytes),effective batch size (batch size / #replicas),elapsed time (us),"
"QPS,IOPS,bandwidth (MB/s),latency samples,min latency (us),max latency (us),avg latency (us),"
"latency P50 (us),latency P75 (us),latency P90 (us),latency P95 (us),latency P99 (us)\n";
if (!outFile) {
throw std::runtime_error("Failed to write to file: " + outFilePath.string());
}
outFile.close();
}
auto elapsedMicro = std::chrono::duration_cast<std::chrono::microseconds>(elapsedTime);

View File

@ -196,7 +196,7 @@ TYPED_TEST(TestResolve, pathRange) {
auto path = PathAt("/a/b/c/d");
Path trace;
auto result = co_await PathResolveOp(*txn, aclCache, SUPER_USER, &trace).pathRange(path);
std::cout << "resolve " << *path.path << " -> " << trace << " " << trace.normalize() << std::endl;
std::cout << "resolve " << *path.path << " -> " << trace << " " << trace.lexically_normal() << std::endl;
CO_ASSERT_OK(result);
CO_ASSERT_TRUE(result->missing.empty()) << result->missing;
CO_ASSERT_EQ(result->getParentId(), c.id);
@ -208,7 +208,7 @@ TYPED_TEST(TestResolve, pathRange) {
auto path = Path("/a/b/c/e");
Path trace;
auto result = co_await PathResolveOp(*txn, aclCache, SUPER_USER, &trace).pathRange(path);
std::cout << "resolve " << path << " -> " << trace << " " << trace.normalize() << std::endl;
std::cout << "resolve " << path << " -> " << trace << " " << trace.lexically_normal() << std::endl;
CO_ASSERT_OK(result);
CO_ASSERT_TRUE(result->missing.empty()) << result->missing;
CO_ASSERT_EQ(result->getParentId(), c.id);
@ -221,7 +221,7 @@ TYPED_TEST(TestResolve, pathRange) {
Path trace;
auto result = co_await PathResolveOp(*txn, aclCache, SUPER_USER, &trace).pathRange(path);
CO_ASSERT_OK(result);
std::cout << "resolve " << *path.path << " -> " << trace << " " << trace.normalize() << std::endl;
std::cout << "resolve " << *path.path << " -> " << trace << " " << trace.lexically_normal() << std::endl;
CO_ASSERT_TRUE(result->missing.empty()) << result->missing;
CO_ASSERT_EQ(result->getParentId(), c.id);
CO_ASSERT_EQ(result->dirEntry.value(), dEntry);