fix profiler sorting
parent
f5886416bf
commit
583807af96
|
@ -46,6 +46,7 @@ namespace blt
|
|||
{
|
||||
volatile void* hell;
|
||||
hell = (void*) &val;
|
||||
(void) hell;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
|
@ -53,6 +54,7 @@ namespace blt
|
|||
{
|
||||
volatile void* hell2;
|
||||
hell2 = (void*) &val;
|
||||
(void) hell2;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
|
@ -60,6 +62,7 @@ namespace blt
|
|||
{
|
||||
volatile void* hell;
|
||||
hell = (void*) &val;
|
||||
(void) hell;
|
||||
return val;
|
||||
}
|
||||
|
||||
|
@ -68,6 +71,7 @@ namespace blt
|
|||
{
|
||||
volatile void* hell2;
|
||||
hell2 = (void*) &val;
|
||||
(void) hell2;
|
||||
return val;
|
||||
}
|
||||
|
||||
|
|
|
@ -21,12 +21,12 @@ namespace blt
|
|||
|
||||
#define SORT_INTERVALS_FUNC_MACRO(use_history, TYPE_END, TYPE_START, TYPE_TOTAL) \
|
||||
[&use_history](const interval_t* a, const interval_t* b) -> bool { \
|
||||
if (use_history){ \
|
||||
if (!use_history){ \
|
||||
auto a_diff = a->TYPE_END - a->TYPE_START; \
|
||||
auto b_diff = b->TYPE_END - b->TYPE_START; \
|
||||
return a_diff > b_diff; \
|
||||
} else { \
|
||||
return a->TYPE_TOTAL > b->TYPE_TOTAL; \
|
||||
return a->TYPE_TOTAL < b->TYPE_TOTAL; \
|
||||
} \
|
||||
}
|
||||
|
||||
|
|
|
@ -14,37 +14,22 @@
|
|||
#include <memory_test.h>
|
||||
#include <blt/parse/argparse.h>
|
||||
#include <utility_test.h>
|
||||
#include <blt/std/system.h>
|
||||
#include <blt/std/utility.h>
|
||||
|
||||
std::function<int(int i)> test{
|
||||
[](int i) -> int {
|
||||
int acc = 1;
|
||||
for (int j = 0; j < i; j++)
|
||||
{
|
||||
acc += j * i;
|
||||
}
|
||||
return acc;
|
||||
return blt::black_box_ret(i);
|
||||
}
|
||||
};
|
||||
|
||||
int test_as_func(int i)
|
||||
int BLT_ATTRIB_NO_INLINE test_as_func(int i)
|
||||
{
|
||||
int acc = 1;
|
||||
for (int j = 0; j < i; j++)
|
||||
{
|
||||
acc += j * i;
|
||||
}
|
||||
return acc;
|
||||
return blt::black_box_ret(i);
|
||||
}
|
||||
|
||||
inline int test_as_func_inline(int i)
|
||||
{
|
||||
int acc = 1;
|
||||
for (int j = 0; j < i; j++)
|
||||
{
|
||||
acc += j * i;
|
||||
}
|
||||
return acc;
|
||||
return blt::black_box_ret(i);
|
||||
}
|
||||
|
||||
std::function<int(int i)> test_func_as_std(&test_as_func);
|
||||
|
@ -60,24 +45,14 @@ class super_func
|
|||
class class_func : public super_func
|
||||
{
|
||||
public:
|
||||
int test(int i) override
|
||||
BLT_ATTRIB_NO_INLINE int test(int i) override
|
||||
{
|
||||
int acc = 1;
|
||||
for (int j = 0; j < i; j++)
|
||||
{
|
||||
acc += j * i;
|
||||
}
|
||||
return acc;
|
||||
return blt::black_box_ret(i);
|
||||
}
|
||||
};
|
||||
|
||||
int (* func_func)(int) = [](int i) -> int {
|
||||
int acc = 1;
|
||||
for (int j = 0; j < i; j++)
|
||||
{
|
||||
acc += j * i;
|
||||
}
|
||||
return acc;
|
||||
return blt::black_box_ret(i);
|
||||
};
|
||||
|
||||
int (* func_func_in)(int) = &test_as_func;
|
||||
|
@ -122,83 +97,83 @@ int main(int argc, const char** argv)
|
|||
blt::tests::nbtRead();
|
||||
}
|
||||
|
||||
runProfilingAndTableTests();
|
||||
//runProfilingAndTableTests();
|
||||
|
||||
//
|
||||
// auto* funy = new class_func;
|
||||
// super_func* virtual_funy = new class_func;
|
||||
//
|
||||
// for (int _ = 0; _ < 10; _++ ) {
|
||||
// int num_of_tests = 10000;
|
||||
// int acc = 1;
|
||||
// BLT_START_INTERVAL("Functions Test", "std::function (lambda)");
|
||||
// acc = 1;
|
||||
// for (int i = 0; i < num_of_tests; i++) {
|
||||
// acc += test(i);
|
||||
// }
|
||||
// BLT_END_INTERVAL("Functions Test", "std::function (lambda)");
|
||||
// BLT_TRACE(acc);
|
||||
//
|
||||
// BLT_START_INTERVAL("Functions Test", "std::function (normal)");
|
||||
// acc = 1;
|
||||
// for (int i = 0; i < num_of_tests; i++) {
|
||||
// acc += test_func_as_std(i);
|
||||
// }
|
||||
// BLT_END_INTERVAL("Functions Test", "std::function (normal)");
|
||||
// BLT_TRACE(acc);
|
||||
//
|
||||
// BLT_START_INTERVAL("Functions Test", "normal function");
|
||||
// acc = 1;
|
||||
// for (int i = 0; i < num_of_tests; i++) {
|
||||
// acc += test_as_func(i);
|
||||
// }
|
||||
// BLT_END_INTERVAL("Functions Test", "normal function");
|
||||
// BLT_TRACE(acc);
|
||||
//
|
||||
// BLT_START_INTERVAL("Functions Test", "(inline) normal function");
|
||||
// acc = 1;
|
||||
// for (int i = 0; i < num_of_tests; i++) {
|
||||
// acc += test_as_func_inline(i);
|
||||
// }
|
||||
// BLT_END_INTERVAL("Functions Test", "(inline) normal function");
|
||||
// BLT_TRACE(acc);
|
||||
//
|
||||
// BLT_START_INTERVAL("Functions Test", "virtual class direct");
|
||||
// acc = 1;
|
||||
// for (int i = 0; i < num_of_tests; i++) {
|
||||
// acc += funy->test(i);
|
||||
// }
|
||||
// BLT_END_INTERVAL("Functions Test", "virtual class direct");
|
||||
// BLT_TRACE(acc);
|
||||
//
|
||||
// BLT_START_INTERVAL("Functions Test", "virtual class");
|
||||
// acc = 1;
|
||||
// for (int i = 0; i < num_of_tests; i++) {
|
||||
// acc += virtual_funy->test(i);
|
||||
// }
|
||||
// BLT_END_INTERVAL("Functions Test", "virtual class");
|
||||
// BLT_TRACE(acc);
|
||||
//
|
||||
// BLT_START_INTERVAL("Functions Test", "funcptr lambda");
|
||||
// acc = 1;
|
||||
// for (int i = 0; i < num_of_tests; i++) {
|
||||
// acc += func_func(i);
|
||||
// }
|
||||
// BLT_END_INTERVAL("Functions Test", "funcptr lambda");
|
||||
// BLT_TRACE(acc);
|
||||
//
|
||||
// BLT_START_INTERVAL("Functions Test", "c function ptr");
|
||||
// acc = 1;
|
||||
// for (int i = 0; i < num_of_tests; i++) {
|
||||
// acc += func_func_in(i);
|
||||
// }
|
||||
// BLT_END_INTERVAL("Functions Test", "c function ptr");
|
||||
// BLT_TRACE(acc);
|
||||
// }
|
||||
//
|
||||
// BLT_PRINT_PROFILE("Functions Test", blt::logging::log_level::NONE, true);
|
||||
// delete virtual_funy;
|
||||
// delete funy;
|
||||
|
||||
auto* funy = new class_func;
|
||||
super_func* virtual_funy = new class_func;
|
||||
|
||||
for (int _ = 0; _ < 100; _++ ) {
|
||||
int num_of_tests = 10000000;
|
||||
int acc = 1;
|
||||
BLT_START_INTERVAL("Functions Test", "std::function (lambda)");
|
||||
acc = 1;
|
||||
for (int i = 0; i < num_of_tests; i++) {
|
||||
acc += test(i);
|
||||
}
|
||||
BLT_END_INTERVAL("Functions Test", "std::function (lambda)");
|
||||
BLT_TRACE(acc);
|
||||
|
||||
BLT_START_INTERVAL("Functions Test", "std::function (normal)");
|
||||
acc = 1;
|
||||
for (int i = 0; i < num_of_tests; i++) {
|
||||
acc += test_func_as_std(i);
|
||||
}
|
||||
BLT_END_INTERVAL("Functions Test", "std::function (normal)");
|
||||
BLT_TRACE(acc);
|
||||
|
||||
BLT_START_INTERVAL("Functions Test", "normal function");
|
||||
acc = 1;
|
||||
for (int i = 0; i < num_of_tests; i++) {
|
||||
acc += test_as_func(i);
|
||||
}
|
||||
BLT_END_INTERVAL("Functions Test", "normal function");
|
||||
BLT_TRACE(acc);
|
||||
|
||||
BLT_START_INTERVAL("Functions Test", "(inline) normal function");
|
||||
acc = 1;
|
||||
for (int i = 0; i < num_of_tests; i++) {
|
||||
acc += test_as_func_inline(i);
|
||||
}
|
||||
BLT_END_INTERVAL("Functions Test", "(inline) normal function");
|
||||
BLT_TRACE(acc);
|
||||
|
||||
BLT_START_INTERVAL("Functions Test", "virtual class direct");
|
||||
acc = 1;
|
||||
for (int i = 0; i < num_of_tests; i++) {
|
||||
acc += funy->test(i);
|
||||
}
|
||||
BLT_END_INTERVAL("Functions Test", "virtual class direct");
|
||||
BLT_TRACE(acc);
|
||||
|
||||
BLT_START_INTERVAL("Functions Test", "virtual class");
|
||||
acc = 1;
|
||||
for (int i = 0; i < num_of_tests; i++) {
|
||||
acc += virtual_funy->test(i);
|
||||
}
|
||||
BLT_END_INTERVAL("Functions Test", "virtual class");
|
||||
BLT_TRACE(acc);
|
||||
|
||||
BLT_START_INTERVAL("Functions Test", "funcptr lambda");
|
||||
acc = 1;
|
||||
for (int i = 0; i < num_of_tests; i++) {
|
||||
acc += func_func(i);
|
||||
}
|
||||
BLT_END_INTERVAL("Functions Test", "funcptr lambda");
|
||||
BLT_TRACE(acc);
|
||||
|
||||
BLT_START_INTERVAL("Functions Test", "c function ptr");
|
||||
acc = 1;
|
||||
for (int i = 0; i < num_of_tests; i++) {
|
||||
acc += func_func_in(i);
|
||||
}
|
||||
BLT_END_INTERVAL("Functions Test", "c function ptr");
|
||||
BLT_TRACE(acc);
|
||||
}
|
||||
|
||||
BLT_PRINT_PROFILE("Functions Test");
|
||||
delete virtual_funy;
|
||||
delete funy;
|
||||
//
|
||||
// binaryTreeTest();
|
||||
//
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
#ifndef BLT_TESTS_PROFILING_TESTS_H
|
||||
#define BLT_TESTS_PROFILING_TESTS_H
|
||||
|
||||
#include "blt/profiling/profiler.h"
|
||||
#include "blt/profiling/profiler_v2.h"
|
||||
#include "blt/std/logging.h"
|
||||
#include "blt/std/time.h"
|
||||
#include "blt/std/format.h"
|
||||
|
@ -17,7 +17,7 @@ void print(const std::vector<std::string>& vtr) {
|
|||
BLT_TRACE(line);
|
||||
}
|
||||
|
||||
static void runProfilingAndTableTests() {
|
||||
[[maybe_unused]] static void runProfilingAndTableTests() {
|
||||
BLT_START_INTERVAL("Help", "SuperSet");
|
||||
|
||||
BLT_END_INTERVAL("Help", "SuperSet");
|
||||
|
@ -38,7 +38,7 @@ static void runProfilingAndTableTests() {
|
|||
BLT_END_INTERVAL("Help", "UnderSet" + std::to_string(i));
|
||||
}
|
||||
|
||||
BLT_PRINT_PROFILE("Help", blt::logging::log_level::TRACE);
|
||||
BLT_PRINT_PROFILE("Help");
|
||||
BLT_TRACE("");
|
||||
|
||||
blt::string::TableFormatter formatter;
|
||||
|
|
Loading…
Reference in New Issue