google/benchmark

[FR] support any platform through user-provided functions

Open

#1,231 建立於 2021年9月24日

在 GitHub 查看
 (0 留言) (0 反應) (0 負責人)C++ (1,539 fork)batch import
enhancementhelp wanted

倉庫指標

Star
 (7,968 star)
PR 合併指標
 (平均合併 4天 2小時) (30 天內合併 19 個 PR)

描述

Is your feature request related to a problem? Please describe. I'd like to use the benchmark suite in a restricted environment which differs from the currently supported platforms, like linux or windows. There might not be a steady clock provided through the libstdc++, nor are pthreads available but a compatibility layer and ultimately my platform exposes its own functions to measure CPU usage for example.

Describe the solution you'd like I've seen there are already platform-specific switches in-place in some functions. I'd like to be able to provide my own implementations or fallbacks for some parts of the suite.

I could think of the following categories, where that would be useful, also including any errors I got:

  • output streams/console: The user could provide their own std::cout, console color detection, etc.
  • thread library: Since this is detected by CMake, there's not much you could to at compile-time.
  • timing functions: Provide your own ProcessCPUUsage, ThreadCPUUsage, etc.
  • cycle clock
  • system info: Like GetSystemName

Describe alternatives you've considered I couldn't really think of any, yet. Maybe I need to write a linux compatible layer, so that the suite would use the linux API, which internally translate all calls according to my platform, but that is quite the undergoing.

Additional context I acknowledge that my request is an bedge-case. However, I think, that by making it possible to provide user-defined fallbacks for all sorts of functionality of the suite, makes it more attractive for other platform and improves its compatibility.

貢獻者指南