-
Notifications
You must be signed in to change notification settings - Fork 3
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
95e6a0e
commit b25639c
Showing
2 changed files
with
38 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
#ifndef TESTS_UNITY_UNITY_CONFIG_H_ | ||
#define TESTS_UNITY_UNITY_CONFIG_H_ | ||
|
||
#define UNITY_INCLUDE_EXEC_TIME | ||
#define UNITY_CLOCK_MS | ||
|
||
#if defined(_WIN32) | ||
#include <time.h> | ||
#define UNITY_TIME_TYPE clock_t | ||
#define UNITY_GET_TIME(t) t = (clock_t)((clock() * 1000) / CLOCKS_PER_SEC) | ||
#define UNITY_EXEC_TIME_START() UNITY_GET_TIME(Unity.CurrentTestStartTime) | ||
#define UNITY_EXEC_TIME_STOP() UNITY_GET_TIME(Unity.CurrentTestStopTime) | ||
#define UNITY_PRINT_EXEC_TIME() { \ | ||
UNITY_UINT execTimeMs = (Unity.CurrentTestStopTime - Unity.CurrentTestStartTime); \ | ||
UnityPrint(" ("); \ | ||
UnityPrintNumberUnsigned(execTimeMs); \ | ||
UnityPrint(" ms)"); \ | ||
} | ||
#elif defined(__unix__) || defined(__APPLE__) | ||
#include <time.h> | ||
#define UNITY_TIME_TYPE struct timespec | ||
#define UNITY_GET_TIME(t) clock_gettime(CLOCK_MONOTONIC, &t) | ||
#define UNITY_EXEC_TIME_START() UNITY_GET_TIME(Unity.CurrentTestStartTime) | ||
#define UNITY_EXEC_TIME_STOP() UNITY_GET_TIME(Unity.CurrentTestStopTime) | ||
#define UNITY_PRINT_EXEC_TIME() { \ | ||
UNITY_UINT execTimeNs = ((Unity.CurrentTestStopTime.tv_sec - Unity.CurrentTestStartTime.tv_sec) * 1000L); \ | ||
execTimeNs += (Unity.CurrentTestStopTime.tv_nsec - Unity.CurrentTestStartTime.tv_nsec); \ | ||
UnityPrint(" ("); \ | ||
UnityPrintNumberUnsigned(execTimeNs); \ | ||
UnityPrint(" ns)"); \ | ||
} | ||
#endif | ||
|
||
#endif /* TESTS_UNITY_UNITY_CONFIG_H_ */ |