Skip to content

Commit

Permalink
release R2108
Browse files Browse the repository at this point in the history
  • Loading branch information
maierkomor committed Aug 31, 2021
1 parent e8f02e3 commit 88e2f49
Show file tree
Hide file tree
Showing 41 changed files with 20,787 additions and 9,533 deletions.
8 changes: 8 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
R2108:
======
- profiing update and fixes
- HC-SR04 display integration
- fix: float formatting fix
- fix: IPv6 related build issues
- fix: Windows is unable to checkout Atrium due to con.man

R2107:
======
- provide available actions via http as /actions.json
Expand Down
File renamed without changes.
67 changes: 6 additions & 61 deletions main/profiling.h → components/logging/profiling.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,11 @@
#define PROFILING_H

#include <sdkconfig.h>
#include <stdlib.h>
#include <esp_timer.h>

#ifdef CONFIG_FUNCTION_TIMING

#if 1
#include <stdlib.h>
#include <esp_timer.h>
#include <chrono>

struct TimeStats
Expand Down Expand Up @@ -57,19 +56,14 @@ struct FProf
#ifdef CONFIG_IDF_TARGET_ESP8266
typedef uint32_t hrtime_t;
#else
typedef std::chrono::time_point<std::chrono::high_resolution_clock> hrtime_t;
typedef int64_t hrtime_t;
#endif

FProf(TimeStats &s)
: stats(s)
{
if (0 == s.level++) {
#ifdef CONFIG_IDF_TARGET_ESP8266
start = esp_timer_get_time();
// asm volatile ("rsr %0, ccount" : "=r"(start));
#else
start = std::chrono::high_resolution_clock::now();
#endif
}
}

Expand All @@ -78,12 +72,10 @@ struct FProf
if (0 == --stats.level) {
#ifdef CONFIG_IDF_TARGET_ESP8266
uint32_t end = esp_timer_get_time();
// uint32_t end;
// asm volatile ("rsr %0, ccount" : "=r"(end));
uint32_t dt = end-start;
#else
hrtime_t end = std::chrono::high_resolution_clock::now();
uint32_t dt = std::chrono::duration_cast<std::chrono::nanoseconds>(end-start).count();
int64_t end = esp_timer_get_time();
int64_t dt = end-start;
#endif
stats.total += dt;
if (dt < stats.low)
Expand All @@ -100,57 +92,10 @@ struct FProf

#define STRINGIFY(x) #x
#define TOSTRING(x) STRINGIFY(x)
#define PROFILE_FUNCTION() static thread_local TimeStats _stats(__FUNCTION__); FProf _prof(_stats)
#define PROFILE_FUNCTION() static TimeStats _stats(__FUNCTION__); FProf _prof(_stats)
#define PROFILE_BLOCK() static thread_local TimeStats _stats(__FILE__ ":" TOSTRING(__LINE__)); FProf _prof(_stats)


#else
#include "log.h"
#include <esp_timer.h>
#include <map>

struct TimeStats
{
uint32_t low = 0, high = 0, total = 0, count = 0;

TimeStats()
{ }

explicit TimeStats(uint32_t dt)
: low(dt)
, high(dt)
, total(dt)
, count(1)
{ }
};

class TimeDelta
{
public:
explicit TimeDelta(const char *n)
: m_start(esp_timer_get_time())
, m_name(n)
{ }

~TimeDelta();

static TimeStats getStats(const char *);
static const std::map<const char *,TimeStats> &getStats()
{ return Stats; }

private:
TimeDelta(const TimeDelta &);
TimeDelta& operator = (const TimeDelta &);

int64_t m_start;
const char *m_name;
static std::map<const char *,TimeStats> Stats;
};

#define PROFILE_FUNCTION() TimeDelta dt(__FUNCTION__);

#endif

#else // disabled

#define PROFILE_FUNCTION()
Expand Down
Loading

0 comments on commit 88e2f49

Please sign in to comment.