MCPcopy Create free account
hub / github.com/MegEngine/MegEngine / benchmark_impl

Function benchmark_impl

dnn/test/naive/warp_perspective.cpp:694–734  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

692#if MEGDNN_WITH_BENCHMARK
693namespace {
694void benchmark_impl(
695 const typename WarpPerspective::Param& param,
696 std::vector<SmallVector<TensorShape>> shapes, size_t RUNS,
697 TaskExecutorConfig&& multi_thread_config,
698 TaskExecutorConfig&& single_thread_config) {
699 std::vector<float> multi_thread_times, single_thread_times;
700 {
701 auto multi_thread_hanle = create_cpu_handle(0, true, &multi_thread_config);
702 auto benchmarker = Benchmarker<WarpPerspective>(multi_thread_hanle.get());
703 benchmarker.set_times(RUNS).set_display(false).set_param(param);
704 for (auto shape : shapes) {
705 multi_thread_times.push_back(benchmarker.exec(shape) / RUNS);
706 }
707 }
708 {
709 auto single_thread_handle = create_cpu_handle(0, true, &single_thread_config);
710 auto benchmarker = Benchmarker<WarpPerspective>(single_thread_handle.get());
711 benchmarker.set_times(RUNS).set_display(false).set_param(param);
712 for (auto shape : shapes) {
713 single_thread_times.push_back(benchmarker.exec(shape) / RUNS);
714 }
715 }
716 printf("Benchmark : Multi threads %zu, ", multi_thread_config.nr_thread);
717 printf("core_ids:");
718 for (size_t i = 0; i < multi_thread_config.affinity_core_set.size(); i++) {
719 printf("%zu ", multi_thread_config.affinity_core_set[i]);
720 }
721 printf(", Single thread core_id %zu\n", single_thread_config.affinity_core_set[0]);
722 for (size_t i = 0; i < shapes.size(); i++) {
723 auto shape = shapes[i];
724 printf("Case: ");
725 for (auto sh : shape)
726 printf("%s ", sh.to_string().c_str());
727 printf("%zu threads time: %f,\n single thread time: "
728 "%f. spead up = %f, speedup/cores=%f\n",
729 multi_thread_config.nr_thread, multi_thread_times[i],
730 single_thread_times[i], single_thread_times[i] / multi_thread_times[i],
731 single_thread_times[i] / multi_thread_times[i] /
732 multi_thread_config.nr_thread);
733 }
734}
735} // namespace
736
737TEST_F(NAIVE_BENCHMARK_MULTI_THREADS, BENCHMARK_WARP_PERSPECTIVE) {

Callers 1

TEST_FFunction · 0.70

Calls 5

getMethod · 0.45
push_backMethod · 0.45
execMethod · 0.45
sizeMethod · 0.45
to_stringMethod · 0.45

Tested by

no test coverage detected