MCPcopy Create free account
hub / github.com/appdevforall/CodeOnTheGo / bench

Function bench

subprojects/llama.cpp/tests/test-sampling.cpp:270–286  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

268}
269
270static void bench(llama_sampler * cnstr, const char * cnstr_name, const std::vector<llama_token_data> & data, int n_iter) {
271 std::vector<llama_token_data> cur(data.size());
272 std::copy(data.begin(), data.end(), cur.begin());
273 llama_token_data_array cur_p = { cur.data(), cur.size(), -1, false };
274 llama_sampler_apply(cnstr, &cur_p);
275 llama_sampler_reset(cnstr);
276 const int64_t t_start = ggml_time_us();
277 for (int i = 0; i < n_iter; i++) {
278 std::copy(data.begin(), data.end(), cur.begin());
279 llama_token_data_array cur_p = { cur.data(), cur.size(), -1, false };
280 llama_sampler_apply(cnstr, &cur_p);
281 llama_sampler_reset(cnstr);
282 }
283 const int64_t t_end = ggml_time_us();
284 llama_sampler_free(cnstr);
285 printf("%-43s: %8.3f us/iter\n", cnstr_name, (t_end - t_start) / (float)n_iter);
286}
287
288#define BENCH(__cnstr, __data, __n_iter) bench((__cnstr), #__cnstr, (__data), (__n_iter))
289

Callers 1

benchMethod · 0.85

Calls 8

llama_sampler_applyFunction · 0.85
llama_sampler_resetFunction · 0.85
ggml_time_usFunction · 0.85
llama_sampler_freeFunction · 0.85
sizeMethod · 0.65
beginMethod · 0.45
endMethod · 0.45
dataMethod · 0.45

Tested by

no test coverage detected