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