-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
314a956
commit b2ba04e
Showing
14 changed files
with
1,153 additions
and
83 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
/* | ||
* author : Shuichi TAKANO | ||
* since : Thu Aug 29 2019 1:19:5 | ||
*/ | ||
|
||
#include "chrono.h" | ||
#include <encoding.h> // read_cycle() | ||
#include <sysctl.h> | ||
#include <bsp.h> | ||
|
||
namespace | ||
{ | ||
|
||
constexpr int CORE_COUNT = 2; | ||
|
||
uint64_t cpuClock_ = 0; | ||
clock_t prevClock_[CORE_COUNT]; | ||
|
||
} // namespace | ||
|
||
void initChrono() | ||
{ | ||
cpuClock_ = sysctl_clock_get_freq(SYSCTL_CLOCK_CPU); | ||
prevClock_[0] = prevClock_[1] = read_cycle(); | ||
|
||
printf("cpu clock: %d\n", (int)cpuClock_); | ||
} | ||
|
||
clock_t getClockCounter() | ||
{ | ||
return read_cycle(); | ||
} | ||
|
||
uint32_t clockToMicroSec(clock_t v) | ||
{ | ||
return v * 1000000 / cpuClock_; | ||
} | ||
|
||
uint32_t getTickTimeInMicroSec() | ||
{ | ||
uint64_t core = current_coreid(); | ||
auto prev = prevClock_[core]; | ||
auto clk = read_cycle(); | ||
auto r = clockToMicroSec(clk - prev); | ||
prevClock_[core] = clk; | ||
return r; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
/* | ||
* author : Shuichi TAKANO | ||
* since : Thu Aug 29 2019 1:18:1 | ||
*/ | ||
#ifndef _69B08F22_6134_1654_1202_ECAB715778AD | ||
#define _69B08F22_6134_1654_1202_ECAB715778AD | ||
|
||
#include <stdint.h> | ||
|
||
#ifdef __cplusplus | ||
extern "C" | ||
{ | ||
#endif | ||
|
||
typedef uint64_t clock_t; | ||
|
||
void initChrono(); | ||
|
||
clock_t getClockCounter(); | ||
uint32_t clockToMicroSec(clock_t v); | ||
|
||
uint32_t getTickTimeInMicroSec(); | ||
|
||
#ifdef __cplusplus | ||
} | ||
#endif | ||
|
||
#endif /* _69B08F22_6134_1654_1202_ECAB715778AD */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.