MCPcopy Create free account
hub / github.com/DmitriBogdanov/UTL / main

Function main

examples/module_profiler/profiling_parallel_section.cpp:5–23  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3#include "include/UTL/parallel.hpp"
4
5int main() {
6 using namespace utl;
7 using namespace std::chrono_literals;
8
9 // Run loop on the main thread
10 UTL_PROFILER("Single-threaded loop")
11 for (int i = 0; i < 30; ++i) std::this_thread::sleep_for(10ms);
12
13 // Run the same loop on 3 threads
14 parallel::set_thread_count(3);
15
16 UTL_PROFILER("Multi-threaded loop")
17 parallel::blocking_loop(parallel::IndexRange{0, 30}, [](int low, int high){
18 UTL_PROFILER("Worker thread loop")
19 for (int i = low; i < high; ++i) std::this_thread::sleep_for(10ms);
20 });
21
22 parallel::set_thread_count(0);
23}

Callers

nothing calls this directly

Calls 2

set_thread_countFunction · 0.50
blocking_loopFunction · 0.50

Tested by

no test coverage detected