Compare commits
3 Commits
8e17765774
...
19c02b4e99
Author | SHA1 | Date | |
---|---|---|---|
19c02b4e99 | |||
0e973feb38 | |||
3af3a72472 |
@ -12,8 +12,12 @@ while [[ $# > 0 ]];do
|
|||||||
RELEASE=true
|
RELEASE=true
|
||||||
shift
|
shift
|
||||||
;;
|
;;
|
||||||
--enable-profiling)
|
--basic-profiling)
|
||||||
ENABLE_PROFILING=true
|
BASIC_PROFILING=true
|
||||||
|
shift
|
||||||
|
;;
|
||||||
|
--full-profiling)
|
||||||
|
FULL_PROFILING=true
|
||||||
shift
|
shift
|
||||||
;;
|
;;
|
||||||
*|-*|--*)
|
*|-*|--*)
|
||||||
@ -46,11 +50,11 @@ echo
|
|||||||
|
|
||||||
# PROFILER
|
# PROFILER
|
||||||
PROFSRC="../src/profiler/timer.c"
|
PROFSRC="../src/profiler/timer.c"
|
||||||
PROFFLAGS="-c"
|
PROFFLAGS="-c "
|
||||||
PROF_BUILD_DIR=prof_build
|
PROF_BUILD_DIR=prof_build
|
||||||
|
|
||||||
# PROCESSOR
|
# PROCESSOR
|
||||||
JSONSRC="../src/json/*.c"
|
JSONSRC="../src/json/*.c "
|
||||||
JSONFLAGS="-c "
|
JSONFLAGS="-c "
|
||||||
JSON_BUILD_DIR=json_build
|
JSON_BUILD_DIR=json_build
|
||||||
|
|
||||||
@ -61,10 +65,18 @@ PROCSRC="./$JSON_BUILD_DIR/*.o \
|
|||||||
./src/processor/main.cpp "
|
./src/processor/main.cpp "
|
||||||
PROCOUT=prochavr
|
PROCOUT=prochavr
|
||||||
|
|
||||||
if [[ $ENABLE_PROFILING == true ]]; then
|
if [[ $BASIC_PROFILING == true ]] || [[ $FULL_PROFILING == true ]]; then
|
||||||
JSONFLAGS+="-DENABLE_PROFILING"
|
if [[ $FULL_PROFILING == true ]]; then
|
||||||
PROCSRC+="./$PROF_BUILD_DIR/*.o"
|
JSONFLAGS+="-DFULL_PROFILING"
|
||||||
PROCFLAGS="-DENABLE_PROFILING"
|
PROCFLAGS="-DFULL_PROFILING"
|
||||||
|
PROFFLAGS+="-DFULL_PROFILING"
|
||||||
|
elif [[ $BASIC_PROFILING == true ]]; then
|
||||||
|
JSONFLAGS+="-DBASIC_PROFILING"
|
||||||
|
PROCFLAGS="-DBASIC_PROFILING"
|
||||||
|
PROFFLAGS+="-DBASIC_PROFILING"
|
||||||
|
fi
|
||||||
|
|
||||||
|
PROCSRC+=./$PROF_BUILD_DIR/*.o
|
||||||
|
|
||||||
mkdir $PROF_BUILD_DIR
|
mkdir $PROF_BUILD_DIR
|
||||||
cd $PROF_BUILD_DIR
|
cd $PROF_BUILD_DIR
|
||||||
|
@ -7,17 +7,29 @@
|
|||||||
#define MAX_PROFILE_SAMPLES 1024
|
#define MAX_PROFILE_SAMPLES 1024
|
||||||
#endif // !MAX_PROFILE_SAMPLES
|
#endif // !MAX_PROFILE_SAMPLES
|
||||||
|
|
||||||
#ifdef ENABLE_PROFILING
|
#ifdef FULL_PROFILING
|
||||||
#define PROFILE_START(COUNT) profile_start(COUNT)
|
|
||||||
#define PROFILE_END profile_end()
|
|
||||||
#define SAMPLE_START(ID, TITLE) sample_start(ID, TITLE)
|
#define SAMPLE_START(ID, TITLE) sample_start(ID, TITLE)
|
||||||
#define SAMPLE_END(ID) sample_end(ID)
|
#define SAMPLE_END(ID) sample_end(ID)
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
void sample_start(u64 id, const char *title);
|
||||||
|
void sample_end(u64 id);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#else
|
#else
|
||||||
#define PROFILE_START(COUNT)
|
|
||||||
#define PROFILE_END
|
|
||||||
#define SAMPLE_START(ID, TITLE)
|
#define SAMPLE_START(ID, TITLE)
|
||||||
#define SAMPLE_END(ID)
|
#define SAMPLE_END(ID)
|
||||||
#endif // ENABLE_PROFILING
|
#endif // FULL_PROFILING
|
||||||
|
|
||||||
|
#if defined(BASIC_PROFILING) || defined(FULL_PROFILING)
|
||||||
|
#define PROFILE_START(COUNT) profile_start(COUNT)
|
||||||
|
#define PROFILE_END profile_end()
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
@ -49,11 +61,13 @@ u64 get_cpu_freq(u64 milliseconds);
|
|||||||
void profile_start(u64 count);
|
void profile_start(u64 count);
|
||||||
void profile_end();
|
void profile_end();
|
||||||
|
|
||||||
void sample_start(u64 id, const char *title);
|
|
||||||
void sample_end(u64 id);
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#else
|
||||||
|
#define PROFILE_START(COUNT)
|
||||||
|
#define PROFILE_END
|
||||||
|
#endif // BASIC_PROFILING || FULL_PROFILING
|
||||||
|
|
||||||
#endif // !TIMER_H
|
#endif // !TIMER_H
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
#include "json/json_entities.h"
|
#include "json/json_entities.h"
|
||||||
#include "aliases.h"
|
#include "aliases.h"
|
||||||
#include "profiler/ids.h"
|
#include "processor/ids.h"
|
||||||
#include "profiler/timer.h"
|
#include "profiler/timer.h"
|
||||||
#include "json/dstring.h"
|
#include "json/dstring.h"
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
#include "json/parser.h"
|
#include "json/parser.h"
|
||||||
#include "aliases.h"
|
#include "aliases.h"
|
||||||
#include "profiler/ids.h"
|
#include "processor/ids.h"
|
||||||
#include "profiler/timer.h"
|
#include "profiler/timer.h"
|
||||||
#include "json/dstring.h"
|
#include "json/dstring.h"
|
||||||
#include "json/json_entities.h"
|
#include "json/json_entities.h"
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#include "haversine.h"
|
#include "haversine.h"
|
||||||
#include "point_types.h"
|
#include "point_types.h"
|
||||||
|
#include "processor/ids.h"
|
||||||
#include "processor/proc_argparser.h"
|
#include "processor/proc_argparser.h"
|
||||||
#include "profiler/ids.h"
|
|
||||||
#include "profiler/timer.h"
|
#include "profiler/timer.h"
|
||||||
#include "json/dstring.h"
|
#include "json/dstring.h"
|
||||||
#include "json/json_entities.h"
|
#include "json/json_entities.h"
|
||||||
|
@ -7,6 +7,7 @@
|
|||||||
|
|
||||||
#include <x86intrin.h>
|
#include <x86intrin.h>
|
||||||
|
|
||||||
|
#if defined(BASIC_PROFILING) || defined(FULL_PROFILING)
|
||||||
typedef struct {
|
typedef struct {
|
||||||
profiler_sample_t samples[MAX_PROFILE_SAMPLES];
|
profiler_sample_t samples[MAX_PROFILE_SAMPLES];
|
||||||
u64 cpu_freq;
|
u64 cpu_freq;
|
||||||
@ -82,10 +83,6 @@ void profile_end() {
|
|||||||
|
|
||||||
u16 time_precision = 16;
|
u16 time_precision = 16;
|
||||||
u16 time_char_count = 20;
|
u16 time_char_count = 20;
|
||||||
u16 duration_char_count = 22;
|
|
||||||
u16 hits_char_count = 10;
|
|
||||||
u16 percentage_precision = 8;
|
|
||||||
u16 percentage_char_count = 12;
|
|
||||||
|
|
||||||
// clang-format off
|
// clang-format off
|
||||||
printf("\n==============================PROFILING==============================\n");
|
printf("\n==============================PROFILING==============================\n");
|
||||||
@ -97,6 +94,12 @@ void profile_end() {
|
|||||||
(unsigned long long)profiler.cpu_freq);
|
(unsigned long long)profiler.cpu_freq);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef FULL_PROFILING
|
||||||
|
u16 duration_char_count = 22;
|
||||||
|
u16 hits_char_count = 10;
|
||||||
|
u16 percentage_precision = 8;
|
||||||
|
u16 percentage_char_count = 12;
|
||||||
|
|
||||||
profiler_sample_t *sample = NULL;
|
profiler_sample_t *sample = NULL;
|
||||||
|
|
||||||
for (u64 i = 0; i < profiler.size; ++i) {
|
for (u64 i = 0; i < profiler.size; ++i) {
|
||||||
@ -121,8 +124,11 @@ void profile_end() {
|
|||||||
|
|
||||||
printf(")\n");
|
printf(")\n");
|
||||||
}
|
}
|
||||||
|
#endif // FULL_PROFILING
|
||||||
}
|
}
|
||||||
|
#endif // BASIC_PROFILING || FULL_PROFILING
|
||||||
|
|
||||||
|
#ifdef FULL_PROFILING
|
||||||
void sample_start(u64 id, const char *title) {
|
void sample_start(u64 id, const char *title) {
|
||||||
if (id >= MAX_PROFILE_SAMPLES) {
|
if (id >= MAX_PROFILE_SAMPLES) {
|
||||||
return;
|
return;
|
||||||
@ -188,15 +194,16 @@ void sample_end(u64 id) {
|
|||||||
profiler_sample_t *parent = sample->parent;
|
profiler_sample_t *parent = sample->parent;
|
||||||
|
|
||||||
if (parent) {
|
if (parent) {
|
||||||
sample->parent->start = now;
|
|
||||||
|
|
||||||
// Add sample duration to all parents. This handles deep call stacks
|
// Add sample duration to all parents. This handles deep call stacks
|
||||||
while (parent) {
|
while (parent) {
|
||||||
parent->children_time += duration;
|
parent->children_time += duration;
|
||||||
|
|
||||||
parent = parent->parent;
|
parent = parent->parent;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sample->parent->start = now;
|
||||||
}
|
}
|
||||||
|
|
||||||
profiler.active = sample->parent;
|
profiler.active = sample->parent;
|
||||||
}
|
}
|
||||||
|
#endif // FULL_PROFILING
|
||||||
|
Loading…
Reference in New Issue
Block a user