[ox/std] Remove SmallMap dtor, replace timing code with steady_clock
This commit is contained in:
parent
3b18869665
commit
407e54246f
7
deps/ox/src/ox/std/smallmap.hpp
vendored
7
deps/ox/src/ox/std/smallmap.hpp
vendored
@ -39,8 +39,6 @@ class SmallMap {
|
||||
|
||||
constexpr SmallMap(SmallMap &&other) noexcept;
|
||||
|
||||
constexpr ~SmallMap();
|
||||
|
||||
constexpr bool operator==(SmallMap const&other) const;
|
||||
|
||||
constexpr SmallMap &operator=(SmallMap const&other);
|
||||
@ -105,11 +103,6 @@ constexpr SmallMap<K, T, SmallSz>::SmallMap(SmallMap<K, T, SmallSz> &&other) noe
|
||||
m_pairs = std::move(other.m_pairs);
|
||||
}
|
||||
|
||||
template<typename K, typename T, size_t SmallSz>
|
||||
constexpr SmallMap<K, T, SmallSz>::~SmallMap() {
|
||||
clear();
|
||||
}
|
||||
|
||||
template<typename K, typename T, size_t SmallSz>
|
||||
constexpr bool SmallMap<K, T, SmallSz>::operator==(SmallMap const&other) const {
|
||||
return m_pairs == other.m_pairs;
|
||||
|
14
deps/ox/src/ox/std/test/tests.cpp
vendored
14
deps/ox/src/ox/std/test/tests.cpp
vendored
@ -18,12 +18,12 @@
|
||||
#include <ox/std/std.hpp>
|
||||
|
||||
[[nodiscard]]
|
||||
static uint64_t nowMs() {
|
||||
static uint64_t steadyNowMs() {
|
||||
#if __has_include(<chrono>)
|
||||
using namespace std::chrono;
|
||||
return static_cast<uint64_t>(
|
||||
duration_cast<milliseconds>(
|
||||
system_clock::now().time_since_epoch()).count());
|
||||
steady_clock::now().time_since_epoch()).count());
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
@ -41,13 +41,13 @@ uint64_t timeMapStrToUuid(int elemCnt, int lookups, uint64_t seed = 4321) noexce
|
||||
auto const keys = map.keys();
|
||||
ox::Random rand;
|
||||
// start
|
||||
auto const startTime = nowMs();
|
||||
auto const startTime = steadyNowMs();
|
||||
for (int i = 0; i < lookups; ++i) {
|
||||
auto const&k = keys[rand.gen() % keys.size()];
|
||||
map[k];
|
||||
oxExpect(map[k], ox::UUID::fromString(k).unwrap());
|
||||
}
|
||||
return nowMs() - startTime;
|
||||
return steadyNowMs() - startTime;
|
||||
}
|
||||
|
||||
template<typename Map = ox::SmallMap<ox::UUID, ox::String>>
|
||||
@ -62,16 +62,16 @@ uint64_t timeMapUuidToStr(int elemCnt, int lookups, uint64_t seed = 4321) noexce
|
||||
auto const keys = map.keys();
|
||||
ox::Random rand;
|
||||
// start
|
||||
auto const startTime = nowMs();
|
||||
auto const startTime = steadyNowMs();
|
||||
for (int i = 0; i < lookups; ++i) {
|
||||
auto const&k = keys[rand.gen() % keys.size()];
|
||||
oxExpect(map[k], k.toString());
|
||||
}
|
||||
return nowMs() - startTime;
|
||||
return steadyNowMs() - startTime;
|
||||
}
|
||||
|
||||
static ox::Error compareMaps(int lookupCnt = 1'000'000) {
|
||||
auto const seed = nowMs();
|
||||
auto const seed = steadyNowMs();
|
||||
uint64_t hashTime{};
|
||||
uint64_t smallTime{};
|
||||
int elemCnt = 1;
|
||||
|
Loading…
Reference in New Issue
Block a user