0

I'm writing a profiler, where different functions should be profiled. Each of the functions, that should be profiled, returns an event, that holds timing data. I don't have access to the implementation of the functions, but have to bundle the returned event with parameters I called the function with.

As example I have the function-call

ev1 = a(parameter,x,y,z)

and

ev2 = b(parameter,foo)

At the end of my programm, I want to collect all events returned from this functions, together with each parameter and ideally with the names of the functions. In this example at the end of my program, I would have something like:

[('a',parameter,ev1),('b',parameter,ev2)]

I thought of doing some kind of wrapper function, but am not sure on how to give the wrapper function the name of all possible functions to be called.

Dschoni
  • 3,714
  • 6
  • 45
  • 80
  • Lots of people have tried to do this, in various languages, but if the reason for doing it is to *identify speedups* (as opposed to just getting measurements), it doesn't find them very well, and there are [*better ways to do it*](http://stackoverflow.com/a/1779343/23771). – Mike Dunlavey Sep 02 '16 at 17:33
  • The reason is getting measurements. The question is more about how to implement something like a universal caller interface for a set of defined functions. – Dschoni Sep 05 '16 at 09:27
  • I'm not sure if decorators is what I'm looking for, but I'll try with using them. – Dschoni Sep 06 '16 at 14:33

0 Answers0