Code Monkey home page Code Monkey logo

perf-utils's People

Contributors

bdrung avatar hodgesds avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

perf-utils's Issues

Provide integration into testing.B

I would like to use your library to count cycles and instructions as a part of a standard Go benchmark for one of my projects. Unfortunately, the current work flow seems to be not as useful as it could be for this purpose: the profileFn function performs the thread locking and set up in one go, causing all the cost for this to become part of the allocation and time counts measured by the benchmark. Additionally, the current set up only allows taking one performance counter per benchmark when taking multiple counters would be a lot more useful.

I think it would be nice to have a function with a signature like this:

func RunBenchmark(b *testing.B, f func(b *testing.B), unix.PerfEventAttr...)

This function would do the following:

  • lock the current Go routine to a thread and set scheduler affinity
  • call b.StopTimer(); b.ResetTimer()
  • run f once for each PerfEventAttr and add the results (divided by b.N) to the benchmark using b.ReportMetric
  • run f once more surrounded by b.StartTimer() and b.StopTimer to get timings and GC usage (optionally do this first?)
  • if a performance counter cannot be measured, it is silently omitted (and optionally logged?)
  • other errors are reported using b.Fatal()

What do you think about something like this? Alternatively or additionally, a benchmark setup function (using b.Cleanup to automatically clean up) and a setup-less profileFn variant could be provided.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.