gapry / algorism Goto Github PK
View Code? Open in Web Editor NEWLicense: MIT License
License: MIT License
I have encountered an issue when trying to use C++ modules with Google Benchmark. Specifically, Google Benchmark fails to compile when attempting to use a class from a C++ module as a template argument.
You can use the following design to reproduce the issue:
#include <benchmark/benchmark.h>
import algorism.string;
template<typename TString>
static void StringAppendCStr(benchmark::State& state) {
const char* const s1 = "Hi Hi! ";
const char* const s2 = "I go to school by bus!";
TString bench_str(s1);
for (auto _ : state) {
bench_str += s2;
}
}
static void BM_Algorism_StringAppendCStr(benchmark::State& state) {
StringAppendCStr<algorism::string>(state);
}
static void BM_STD_StringAppendCStr(benchmark::State& state) {
StringAppendCStr<std::string>(state);
}
BENCHMARK(BM_Algorism_StringAppendCStr)->Iterations(1024);
BENCHMARK(BM_STD_StringAppendCStr)->Iterations(1024);
The corresponding error report:
error: no matching function for call to 'StringAppendCStr'
StringAppendCStr<algorism::string>(state);
At the moment, I am using the following workaround by not using the templates with the module class and instead defining benchmark functions for each type:
void BM_Algorism_StringAppendCStr(benchmark::State& state) {
const char* const s1 = "Hi Hi! ";
const char* const s2 = "I go to school by bus!";
algorism::string bench_str(s1);
for (auto _ : state) {
bench_str += s2;
}
}
BENCHMARK(BM_Algorism_StringAppendCStr)->Iterations(1024);
void BM_STD_StringAppendCStr(benchmark::State& state) {
const char* const s1 = "Hi Hi! ";
const char* const s2 = "I go to school by bus!";
std::string bench_str(s1);
for (auto _ : state) {
bench_str += s2;
}
}
BENCHMARK(BM_STD_StringAppendCStr)->Iterations(1024);
I mention it here because it's not critical at the moment. I'll try to fix it when I have time.
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.