mirror of
https://github.com/ggerganov/llama.cpp.git
synced 2024-11-13 14:29:52 +00:00
llama-bench : add time-to-first-byte stat
This commit is contained in:
parent
64c6af3195
commit
ff231de553
@ -931,6 +931,13 @@ struct test {
|
|||||||
return ts;
|
return ts;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::vector<double> get_ttfb() const {
|
||||||
|
int n_tokens = n_prompt + n_gen;
|
||||||
|
std::vector<double> ts;
|
||||||
|
std::transform(samples_ns.begin(), samples_ns.end(), std::back_inserter(ts), [n_tokens](uint64_t t) { return t/1e6; });
|
||||||
|
return ts;
|
||||||
|
}
|
||||||
|
|
||||||
double avg_ts() const {
|
double avg_ts() const {
|
||||||
return ::avg(get_ts());
|
return ::avg(get_ts());
|
||||||
}
|
}
|
||||||
@ -939,6 +946,14 @@ struct test {
|
|||||||
return ::stdev(get_ts());
|
return ::stdev(get_ts());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
double avg_ttfb() const {
|
||||||
|
return ::avg(get_ttfb());
|
||||||
|
}
|
||||||
|
|
||||||
|
double stdev_ttfb() const {
|
||||||
|
return ::stdev(get_ttfb());
|
||||||
|
}
|
||||||
|
|
||||||
static std::string get_backend() {
|
static std::string get_backend() {
|
||||||
if (cuda) {
|
if (cuda) {
|
||||||
return GGML_CUDA_NAME;
|
return GGML_CUDA_NAME;
|
||||||
@ -1189,6 +1204,9 @@ struct markdown_printer : public printer {
|
|||||||
if (field == "model") {
|
if (field == "model") {
|
||||||
return -30;
|
return -30;
|
||||||
}
|
}
|
||||||
|
if (field == "ttfb") {
|
||||||
|
return 30;
|
||||||
|
}
|
||||||
if (field == "t/s") {
|
if (field == "t/s") {
|
||||||
return 20;
|
return 20;
|
||||||
}
|
}
|
||||||
@ -1316,6 +1334,7 @@ struct markdown_printer : public printer {
|
|||||||
}
|
}
|
||||||
fields.emplace_back("test");
|
fields.emplace_back("test");
|
||||||
fields.emplace_back("t/s");
|
fields.emplace_back("t/s");
|
||||||
|
fields.emplace_back("ttfb");
|
||||||
|
|
||||||
fprintf(fout, "|");
|
fprintf(fout, "|");
|
||||||
for (const auto & field : fields) {
|
for (const auto & field : fields) {
|
||||||
@ -1370,6 +1389,9 @@ struct markdown_printer : public printer {
|
|||||||
} else if (field == "t/s") {
|
} else if (field == "t/s") {
|
||||||
snprintf(buf, sizeof(buf), "%.2f ± %.2f", t.avg_ts(), t.stdev_ts());
|
snprintf(buf, sizeof(buf), "%.2f ± %.2f", t.avg_ts(), t.stdev_ts());
|
||||||
value = buf;
|
value = buf;
|
||||||
|
} else if (field == "ttfb") {
|
||||||
|
snprintf(buf, sizeof(buf), "%.2f ± %.2f", t.avg_ttfb(), t.stdev_ttfb());
|
||||||
|
value = buf;
|
||||||
} else if (vmap.find(field) != vmap.end()) {
|
} else if (vmap.find(field) != vmap.end()) {
|
||||||
value = vmap.at(field);
|
value = vmap.at(field);
|
||||||
} else {
|
} else {
|
||||||
@ -1378,7 +1400,7 @@ struct markdown_printer : public printer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int width = get_field_width(field);
|
int width = get_field_width(field);
|
||||||
if (field == "t/s") {
|
if (field == "t/s" || field == "ttfb") {
|
||||||
// HACK: the utf-8 character is 2 bytes
|
// HACK: the utf-8 character is 2 bytes
|
||||||
width += 1;
|
width += 1;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user