mseryn / mantis-monitor

Mantis-monitor, a suite to perform code-external profiling using a range of standard profiling tools and producing one data format
GNU Lesser General Public License v2.1
1 stars 0 forks source link

generate_benchmarks improvements #41

Closed hgreenbl closed 2 years ago

hgreenbl commented 2 years ago

Makes the default generate_benchmarks heritable (are you familiar with the semantics of @classmethod?) and simplifies the interface a bit.

We should consider adding a utility function for the cartesian-product pattern (e.g. c1b14cdd772f3d6acae60659ac17fcac13862603) since it's likely to be common.

mseryn commented 2 years ago

Agreed about a utility library. Let's make it a separate issue for a wishlist later. @hgreenbl Will you open this issue?

mseryn commented 2 years ago

Why classmethod instead of staticmethod?

mseryn commented 2 years ago

Let me know what you think on comments. =)

hgreenbl commented 2 years ago

Agreed about a utility library. Let's make it a separate issue for a wishlist later. @hgreenbl Will you open this issue?

42


Why classmethod instead of staticmethod?

Did you read the docs I linked?

A class method receives the class as an implicit first argument, just like an instance method receives the instance. ... If a class method is called for a derived class, the derived class object is passed as the implied first argument.

This way, any class that inherits from Benchmark also inherits (if it doesn't choose to override) the default generate_benchmarks implementation, which will return a single-item list but call the derived class's constructor to populate it.

(It also reduces repetition, which improves maintainability for the usual reasons.)

mseryn commented 2 years ago

Read the docs, not sure how this is different from staticmethod for our use case.

mseryn commented 2 years ago

Probably my lack of understanding, not arguing, but need to understand