diff --git a/lib/include/bofstd/bofstd.h b/lib/include/bofstd/bofstd.h index a0cfe7e..76f9e73 100644 --- a/lib/include/bofstd/bofstd.h +++ b/lib/include/bofstd/bofstd.h @@ -40,12 +40,16 @@ cmake -DCMAKE_TOOLCHAIN_FILE=C:/pro/vcpkg/scripts/buildsystems/vcpkg.cmake -DBUI #include typedef bool(WINAPI *BofSignalHandler)(uint32_t); #else -typedef bool (*BofSignalHandler)(uint32_t); -#endif -using BofAssertCallback = std::function; #if defined(__EMSCRIPTEN__) +#include //for emscripten_performance_now in Bof_RdTsc using BofEmscriptenCallback = std::function; +#else +#include //for __rdtsc in Bof_RdTsc +#endif +typedef bool (*BofSignalHandler)(uint32_t); #endif + +using BofAssertCallback = std::function; #include //Autogenerated by cmake #define BOF onbings::bof @@ -646,10 +650,16 @@ extern uint32_t GL_BofDbgPrintfStartTime_U32; // Intrinsyc fct inline BOFSTD_EXPORT uint64_t Bof_RdTsc() { - // uint32_t low, high; - // asm volatile ("rdtsc" : "=a" (low), "=d" (high)); - // return (((uint64_t)high << 32) | low); +#if defined(__EMSCRIPTEN__) + /* + uint32_t Low_U32, High_U32; + asm volatile ("rdtsc" : "=a" (Low_U32), "=d" (High_U32)); + return (((uint64_t)High_U32 << 32) | Low_U32); + */ + return static_cast(emscripten_performance_now() * 1000000.0); //Calls JavaScript performance.now(), returns a high precision wallclock time value in msecs. +#else return __rdtsc(); +#endif } BOFSTD_EXPORT uint32_t Bof_MeasureCpuSpeedInMHz(); diff --git a/tests/src/ut_circularbuffer.cpp b/tests/src/ut_circularbuffer.cpp index 40c3424..1d6d504 100644 --- a/tests/src/ut_circularbuffer.cpp +++ b/tests/src/ut_circularbuffer.cpp @@ -659,7 +659,7 @@ TEST(CircularBuffer_Test, Perf) Index_U32 = 0; } } - printf("%zd Push Min %zd Mean %zd Max %zd Lck %zd\n", Profiler.GetNbSample(0), Profiler.GetMin(0), Profiler.GetMean(0), Profiler.GetMax(0), Profiler.GetLockCount(0)); + printf("%llu Push Min %llu Mean %llu Max %llu Lck %llu\n", Profiler.GetNbSample(0), Profiler.GetMin(0), Profiler.GetMean(0), Profiler.GetMax(0), Profiler.GetLockCount(0)); Index_U32 = 0; for (i_U32 = 0; i_U32 < NB_QUEUE_OP; i_U32++) @@ -676,7 +676,7 @@ TEST(CircularBuffer_Test, Perf) } } EXPECT_NE(Cb.Pop(&Item_X, 1000, nullptr, nullptr), BOF_ERR_NO_ERROR); - printf("%zu Pop Min %zu Mean %zu Max %zu Lck %zu\n", Profiler.GetNbSample(1), Profiler.GetMin(1), Profiler.GetMean(1), Profiler.GetMax(1), Profiler.GetLockCount(1)); + printf("%llu Pop Min %llu Mean %llu Max %llu Lck %llu\n", Profiler.GetNbSample(1), Profiler.GetMin(1), Profiler.GetMean(1), Profiler.GetMax(1), Profiler.GetLockCount(1)); } TEST(CircularBuffer_Test, PerfThread) @@ -765,22 +765,22 @@ TEST(CircularBuffer_Test, PerfThread) for (i_U32 = 0; i_U32 < NB_QUEUE_PRODUCER_CONSUMER; i_U32++) { NbLastMax_U32 = Profiler.GetLastMax(i_U32, pLastMax_X); - printf("NbOp %zu NbMax %d Push[%d] Min %zu Mean %zu Max %zu Lck %zu\n", Profiler.GetNbSample(i_U32), NbLastMax_U32, i_U32, Profiler.GetMin(i_U32), Profiler.GetMean(i_U32), Profiler.GetMax(i_U32), Profiler.GetLockCount(i_U32)); + printf("NbOp %llu NbMax %d Push[%d] Min %llu Mean %llu Max %llu Lck %llu\n", Profiler.GetNbSample(i_U32), NbLastMax_U32, i_U32, Profiler.GetMin(i_U32), Profiler.GetMean(i_U32), Profiler.GetMax(i_U32), Profiler.GetLockCount(i_U32)); EXPECT_EQ(Profiler.GetNbSample(i_U32), NB_QUEUE_OP); for (j_U32 = 0; j_U32 < NbLastMax_U32; j_U32++) { - printf(" Index %zu Max %zu\n", pLastMax_X[j_U32].MaxIndex_U64, pLastMax_X[j_U32].Max); + printf(" Index %llu Max %llu\n", pLastMax_X[j_U32].MaxIndex_U64, pLastMax_X[j_U32].Max); } } printf("---POP---------------------------\n"); for (i_U32 = NB_QUEUE_PRODUCER_CONSUMER; i_U32 < (NB_QUEUE_PRODUCER_CONSUMER + NB_QUEUE_PRODUCER_CONSUMER); i_U32++) { NbLastMax_U32 = Profiler.GetLastMax(i_U32, pLastMax_X); - printf("NbOp %zu NbMax %d Pop[%d] Min %zu Mean %zu Max %zu Lck %zu\n", Profiler.GetNbSample(i_U32), NbLastMax_U32, i_U32, Profiler.GetMin(i_U32), Profiler.GetMean(i_U32), Profiler.GetMax(i_U32), Profiler.GetLockCount(i_U32)); + printf("NbOp %llu NbMax %d Pop[%d] Min %llu Mean %llu Max %llu Lck %llu\n", Profiler.GetNbSample(i_U32), NbLastMax_U32, i_U32, Profiler.GetMin(i_U32), Profiler.GetMean(i_U32), Profiler.GetMax(i_U32), Profiler.GetLockCount(i_U32)); EXPECT_EQ(Profiler.GetNbSample(i_U32), NB_QUEUE_OP); for (j_U32 = 0; j_U32 < NbLastMax_U32; j_U32++) { - printf(" Index %zu Max %zu\n", pLastMax_X[j_U32].MaxIndex_U64, pLastMax_X[j_U32].Max); + printf(" Index %llu Max %llu\n", pLastMax_X[j_U32].MaxIndex_U64, pLastMax_X[j_U32].Max); } } } \ No newline at end of file diff --git a/vcpkg.json b/vcpkg.json index 5b72a89..800aed1 100644 --- a/vcpkg.json +++ b/vcpkg.json @@ -1,6 +1,6 @@ { "name": "bofstd", - "version": "5.6.0.3", + "version": "5.6.0.4", "description": "The onbings general purpose C++ Multiplatform library", "dependencies": [ {