mirror of https://github.com/orefkov/simstr.git
Update results
This commit is contained in:
parent
317a4c5994
commit
c0dfdd4ef5
|
|
@ -3,6 +3,7 @@
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <array>
|
#include <array>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
#include <map>
|
||||||
|
|
||||||
using namespace simstr;
|
using namespace simstr;
|
||||||
|
|
||||||
|
|
@ -193,41 +194,46 @@ void write_one_result(out_t& out, ssa result, ssa line, auto& script_text, bool
|
||||||
script_text += e_choice(result[0] == 'N', "NaN", result) + e_choice(last, "]", ",");
|
script_text += e_choice(result[0] == 'N', "NaN", result) + e_choice(last, "]", ",");
|
||||||
}
|
}
|
||||||
|
|
||||||
ssa extract_source_for_benchmark(ssa benchName, ssa sourceText) {
|
std::pair<ssa, size_t> extract_source_for_benchmark(ssa benchName, ssa sourceText) {
|
||||||
if (benchName == "ReplaceStr") {
|
static hashStrMapA<std::pair<stringa, size_t>> textes;
|
||||||
int t = 0;
|
static auto lines_pos = [&]() {
|
||||||
}
|
std::map<size_t, size_t> l = {{0, 0}};
|
||||||
static hashStrMapA<stringa> textes;
|
size_t line = 0;
|
||||||
|
sourceText.for_all_finded([&](size_t pos){
|
||||||
|
l.emplace(pos, ++line);
|
||||||
|
}, "\n");
|
||||||
|
return l;
|
||||||
|
}();
|
||||||
|
|
||||||
size_t delim = benchName.find_last('/');
|
size_t delim = benchName.find_last('/');
|
||||||
if (delim != str::npos && benchName(delim + 1).to_int<unsigned, false, 10, false, false>().ec == IntConvertResult::Success) {
|
if (delim != str::npos && benchName(delim + 1).to_int<unsigned, false, 10, false, false>().ec == IntConvertResult::Success) {
|
||||||
benchName.len = delim;
|
benchName.len = delim;
|
||||||
}
|
}
|
||||||
auto [it, not_exist] = textes.try_emplace(benchName);
|
auto [it, not_exist] = textes.try_emplace(benchName, stringa{}, 0);
|
||||||
if (not_exist) {
|
if (not_exist) {
|
||||||
// Ищем имя функции для этого бенчмарка
|
// Ищем имя функции для этого бенчмарка
|
||||||
// Looking for the name of the function for this benchmark
|
// Looking for the name of the function for this benchmark
|
||||||
size_t start = sourceText.find(lstringa<128>{"->Name(\"" + e_repl(benchName, "\"", "\\\"") + "\")"});
|
size_t start = sourceText.find(lstringa<128>{"->Name(\"" + e_repl(benchName, "\"", "\\\"") + "\")"});
|
||||||
if (start == str::npos) {
|
if (start == str::npos) {
|
||||||
std::cerr << "Can not found benchmark function name for " << benchName << std::endl;
|
std::cerr << "Can not found benchmark function name for " << benchName << std::endl;
|
||||||
return stra::empty_str;
|
return {stra::empty_str, 0};
|
||||||
}
|
}
|
||||||
start = sourceText(0, start).find('(', sourceText.find_last('\n', start - 1));
|
start = sourceText(0, start).find('(', sourceText.find_last('\n', start - 1));
|
||||||
if (start == str::npos) {
|
if (start == str::npos) {
|
||||||
std::cerr << "Can not found benchmark function name for " << benchName << std::endl;
|
std::cerr << "Can not found benchmark function name for " << benchName << std::endl;
|
||||||
return stra::empty_str;
|
return {stra::empty_str, 0};
|
||||||
}
|
}
|
||||||
start++;
|
start++;
|
||||||
size_t end = sourceText.find_first_of(")<,", start);
|
size_t end = sourceText.find_first_of(")<,", start);
|
||||||
ssa funcName = sourceText.from_to(start, end);
|
ssa funcName = sourceText.from_to(start, end);
|
||||||
auto [func_it, not_exist] = textes.try_emplace(funcName);
|
auto [func_it, not_exist] = textes.try_emplace(funcName, stringa{}, 0);
|
||||||
if (not_exist) {
|
if (not_exist) {
|
||||||
// Теперь ищем саму эту функцию
|
// Теперь ищем саму эту функцию
|
||||||
// Now we look for this function itself
|
// Now we look for this function itself
|
||||||
start = sourceText.find(lstringa<128>{funcName + "(benchmark::State"});
|
start = sourceText.find(lstringa<128>{funcName + "(benchmark::State"});
|
||||||
if (start == str::npos) {
|
if (start == str::npos) {
|
||||||
std::cerr << "Can not found source function " << funcName << " for benchmark " << benchName << std::endl;
|
std::cerr << "Can not found source function " << funcName << " for benchmark " << benchName << std::endl;
|
||||||
return stra::empty_str;
|
return {stra::empty_str, 0};
|
||||||
}
|
}
|
||||||
start = sourceText.find_last('\n', start);
|
start = sourceText.find_last('\n', start);
|
||||||
size_t templ_start = sourceText.find_last('\n', start) + 1;
|
size_t templ_start = sourceText.find_last('\n', start) + 1;
|
||||||
|
|
@ -255,15 +261,16 @@ ssa extract_source_for_benchmark(ssa benchName, ssa sourceText) {
|
||||||
throw std::runtime_error{"Not found end of func"};
|
throw std::runtime_error{"Not found end of func"};
|
||||||
}
|
}
|
||||||
lstringa<2048> text{sourceText.from_to(beginLine, end + indent.length() + 1), indent, "\n"};
|
lstringa<2048> text{sourceText.from_to(beginLine, end + indent.length() + 1), indent, "\n"};
|
||||||
func_it->second = repl_html_symbols(text(1));
|
func_it->second.first = repl_html_symbols(text(1));
|
||||||
} else {
|
} else {
|
||||||
end = sourceText.find("\n}\n", start);
|
end = sourceText.find("\n}\n", start);
|
||||||
func_it->second = repl_html_symbols(sourceText.from_to(start, end + 2));
|
func_it->second.first = repl_html_symbols(sourceText.from_to(start, end + 2));
|
||||||
}
|
}
|
||||||
|
func_it->second.second = lines_pos.lower_bound(start)->second;
|
||||||
}
|
}
|
||||||
it->second = func_it->second;
|
it->second = func_it->second;
|
||||||
}
|
}
|
||||||
return it->second;
|
return {it->second.first, it->second.second};
|
||||||
}
|
}
|
||||||
|
|
||||||
void write_benchmarks(out_t& out, const results_vector& results, ssa sourceText, ssa commentsText) {
|
void write_benchmarks(out_t& out, const results_vector& results, ssa sourceText, ssa commentsText) {
|
||||||
|
|
@ -280,13 +287,13 @@ void write_benchmarks(out_t& out, const results_vector& results, ssa sourceText,
|
||||||
ssa line = splitters[0].next(), benchName, result;
|
ssa line = splitters[0].next(), benchName, result;
|
||||||
if (auto rm = line.find("_mean"); rm != str::npos) {
|
if (auto rm = line.find("_mean"); rm != str::npos) {
|
||||||
benchName = extract_name_result(line, result)(0, rm);
|
benchName = extract_name_result(line, result)(0, rm);
|
||||||
auto source = extract_source_for_benchmark(benchName, sourceText);
|
auto [source, line_num] = extract_source_for_benchmark(benchName, sourceText);
|
||||||
auto comment = extract_comment(commentsText, benchName);
|
auto comment = extract_comment(commentsText, benchName);
|
||||||
// Нужно вывести название бенча и коммент
|
// Нужно вывести название бенча и коммент
|
||||||
// Need to display title and comment
|
// Need to display title and comment
|
||||||
out += "\n<tr><td class=\"benchmarkname\"><span class=\"tooltip\">" +
|
out += "\n<tr><td class=\"benchmarkname\"><span class=\"tooltip\"><a target=\"blank\" href=\"https://github.com/orefkov/simstr/blob/main/bench/bench_str.cpp#L"_ss +
|
||||||
repl_html_symbols(benchName) +
|
line_num + "\">" + repl_html_symbols(benchName) +
|
||||||
"<span class=\"tooltiptext code\">" +
|
"</a><span class=\"tooltiptext code\">" +
|
||||||
source + "</span></span></td><td>" +
|
source + "</span></span></td><td>" +
|
||||||
e_if(!comment.is_empty(), "<span class=\"tooltip info\"> >> <span class=\"tooltiptext\">" + comment + "</span></span>") +
|
e_if(!comment.is_empty(), "<span class=\"tooltip info\"> >> <span class=\"tooltiptext\">" + comment + "</span></span>") +
|
||||||
"</td>";
|
"</td>";
|
||||||
|
|
|
||||||
|
|
@ -19,6 +19,19 @@ table th {
|
||||||
text-align: center;
|
text-align: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.tooltip a:any-link {
|
||||||
|
text-decoration: none;
|
||||||
|
}
|
||||||
|
.tooltip a:link {
|
||||||
|
color: black;
|
||||||
|
}
|
||||||
|
.tooltip a:visited {
|
||||||
|
color: black;
|
||||||
|
}
|
||||||
|
.tooltip a:hover {
|
||||||
|
text-decoration: underline;
|
||||||
|
}
|
||||||
|
|
||||||
table tr:hover td {
|
table tr:hover td {
|
||||||
background-color: lightcyan;
|
background-color: lightcyan;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue