Download chips/yosys/tests/unit/kernel/perfHelpers.h from STAR-future/Trinity-SciData: direct link, hf CLI and curl.
- Browser
- Download file 1.23 kB
-
https://huggingface.co/datasets/STAR-future/Trinity-SciData/resolve/main/chips/yosys/tests/unit/kernel/perfHelpers.h
- Command line
-
hf download hf://datasets/STAR-future/Trinity-SciData/chips/yosys/tests/unit/kernel/perfHelpers.h
-
curl -L -o perfHelpers.h https://huggingface.co/datasets/STAR-future/Trinity-SciData/resolve/main/chips/yosys/tests/unit/kernel/perfHelpers.h
1.23 kB
| YOSYS_NAMESPACE_BEGIN | |
| inline int env_int(const char *name, int fallback) | |
| { | |
| const char *value = getenv(name); | |
| if (value == nullptr || *value == 0) | |
| return fallback; | |
| return atoi(value); | |
| } | |
| inline size_t rss_bytes() | |
| { | |
| size_t total_pages = 0, resident_pages = 0; | |
| FILE *f = fopen("/proc/self/statm", "r"); | |
| if (f == nullptr) | |
| return 0; | |
| if (fscanf(f, "%zu %zu", &total_pages, &resident_pages) != 2) | |
| resident_pages = 0; | |
| fclose(f); | |
| return resident_pages * (size_t)sysconf(_SC_PAGESIZE); | |
| return 0; | |
| } | |
| inline size_t peak_rss_bytes() | |
| { | |
| struct rusage ru; | |
| if (getrusage(RUSAGE_SELF, &ru) != 0) | |
| return 0; | |
| return (size_t)ru.ru_maxrss * 1024; | |
| return 0; | |
| } | |
| inline double mb(size_t bytes) | |
| { | |
| return bytes / 1048576.0; | |
| } | |
| inline double ms(std::chrono::steady_clock::duration d) | |
| { | |
| return std::chrono::duration<double, std::milli>(d).count(); | |
| } | |
| YOSYS_NAMESPACE_END | |