sunxfancy / zeroerr Goto Github PK
View Code? Open in Web Editor NEWA powerful C++ unit testing/assert/log utils
Home Page: https://sunxfancy.github.io/zeroerr/en/html/
License: MIT License
A powerful C++ unit testing/assert/log utils
Home Page: https://sunxfancy.github.io/zeroerr/en/html/
License: MIT License
@bfjm 之前你提到的关于log多线程写入的问题,现在代码中的实现还比较粗糙,只有一个简单的lock-free的队列。并且你说的没错,很多log系统在多线程处理时,都会使用额外的线程来异步写入来避免对原有工作的干扰,这点非常有必要。
也许你可以帮忙建立一个多线程的写入的benchmark,测试一下性能和可靠性,并研究一下怎么样优化log的写入。我们的Test Case是可以添加Benchmark的,在test/log_test.cpp下,有一个这样的一段代码就是用来测试性能的:
BENCHMARK("speedtest") {
#ifdef ZEROERR_OS_UNIX
uint64_t* data = new uint64_t[1000000];
FILE* file = fmemopen(data, 1000000 * sizeof(uint64_t), "w");
FILE* oldstdout = stdout;
FILE* oldstderr = stderr;
stdout = stderr = file;
#endif
zeroerr::LogStream::getDefault().setFlushManually();
std::stringstream ss;
Benchmark bench("log speed test");
bench.run("spdlog", [] { spdlog::info("hello world {:03.2f}", 1.1); })
.run("stringstream",
[&] {
ss << "hello world " << 1.1;
doNotOptimizeAway(ss);
})
.run("log", [] { LOG("hello world {value}", 1.1); })
.report();
zeroerr::LogStream::getDefault().setFlushAtOnce();
#ifdef ZEROERR_OS_UNIX
stdout = oldstdout;
stderr = oldstderr;
fclose(file);
delete[] data;
#endif
}
不过对于像一些高级profiling的功能,只有linux下才能用perf库收集。我一直想让这个东西支持windows,但无奈windows硬件寄存器太难读取了,我写了一些单独的测试代码去收集硬件信息,但一直没能找到将其整合起来的方法。如果你有兴趣也可以看下 https://github.com/sunxfancy/Win32Perf ,不过这个功能优先级比较低,并不是那么紧要。
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.