Frameworks for performance testing at the unit test level (code level)

Hello,
Has anybody experience with frameworks for performance testing at the unit test level (code level)? The idea is to be able to trace request and check response times.
Thanks.

Not exactly a true answer to your question - I’ve not used a framework per se, but I did stumble across this blog about googletest: https://www.bfilipek.com/2016/05/google-benchmark-library.html. In my previous life as a developer I used what was built into the runtime to add {timestamp,line} to a hashmap.

Though you mention request and response - are you interested in testing latency?

Isn’t a simple timer before and after the target function of a unit check enough?

mock1 = Mock()
mock2 = Mock()
target = Target(mock1, mock2)
time_before = time.now()
result = target.doFunStuff()
assert(result == “blablabla”)
log.time(time.now() - time_before)

I’m not sure what you are trying to accomplish. In unit testing you typically have gotten rid of all integrations which leaves very little to actually performance test. But I guess if we are talking about response times you have some integrations in place that you want to test.

In one place we used Gatling https://gatling.io/open-source/ to have a set of performance test that we performed when doing the building of the service. This allows you to easily maintain the performance test code together with the rest of the code. Similar to unit tests.

Hope that helps.