Files
cpp-project-template/examples/microprofile_demo.cc

34 lines
750 B
C++
Raw Normal View History

2025-08-25 12:01:16 +08:00
#include <microprofile.h>
#include <stdio.h>
#include <chrono>
#include <thread>
MICROPROFILE_DEFINE(MAIN, "MAIN", "Main", MP_AUTO);
void Test()
{
2025-08-25 15:24:22 +08:00
MICROPROFILE_SCOPEI("sleep-test", "sleep_for_ms", MP_AUTO);
std::this_thread::sleep_for(std::chrono::milliseconds(1));
2025-08-25 12:01:16 +08:00
}
int main()
{
MicroProfileOnThreadCreate("Main");
MicroProfileSetEnableAllGroups(true);
MicroProfileSetForceMetaCounters(true);
printf("port: %d\n", MicroProfileWebServerPort());
2025-08-25 15:24:22 +08:00
// MicroProfileStartAutoFlip(30);
2025-08-25 12:01:16 +08:00
while (true)
{
2025-08-25 15:24:22 +08:00
MicroProfileFlip(0);
MICROPROFILE_COUNTER_ADD("test_counter", 1);
2025-08-25 12:01:16 +08:00
MICROPROFILE_SCOPE(MAIN);
Test();
}
MicroProfileStopAutoFlip();
MicroProfileShutdown();
return 0;
}