You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Aug 28, 2021. It is now read-only.
We use https://github.com/stretchr/testify extensively, both in unit tests and at runtime (for assertions) and have had lots of perf problems with it over the months, mostly due to its use of reflection.
We should just replace this with a simpler version that doesn't use reflection. We don't need that capability, either for our tests or anything else.
In our dbg package, we created a struct that wraps stretchr/testify/assert so we can do things like Chk.Equal() -- analogous to CHECK_EQ() from the Chromium world.
The stretchr stuff is meant to be used in tests, so it's not particularly performant; specifically, the Equal() predicate does reflection to determine if the two things you pass it are comparable. In some of our hot code paths, this adds a lot of runtime -- calling it in ref.Ref.Less() added 15% overhead or so in our initial xml_importer code. It seems to be related not only to the time spent in reflection, but also triggering a fair amount of garbage collection.
We tried creating a Chk.NaiveEqual() predicate that just took whatever you passed it and compared them using !=, but this proved to only save about half the time vs. comparing the values directly and passing the result to Chk.True().