top of page

Performance Test: Unorderedmap vs filesystem

  • Writer: Pablo Narvaja
    Pablo Narvaja
  • Jan 7, 2020
  • 1 min read

In the previous post about the asset manager I questioned myself if caching the files in the directory was worth it.

Set up


Test

I ran a test 10 times for a 100.000 misses (files that dont exists in the directory).

Filesystem uses the std::filesystem::exists(path) available since c++17. And unordered_map uses map.find(key). The results of the test where made pretty clear which one is better:



Average times: Filesystem: 994.372ms unordered_map: 23.1418ms

The map had 10.000 items in it. The find() function is O(1) most of the times but can be O(n) if all key hashes collide.


Unordered map require a time to be set up but is worth it at runtime.


Conclusion

From this test I can be sure that my AssetManager implementation was worth it.


That's all for this post, folks. Bye!


Comments


  • facebook
  • linkedin
  • youtube
  • generic-social-link
  • Grey LinkedIn Icon
  • Facebook
  • YouTube

2019 Pablo Narvaja. Llamathrust GameEngine

bottom of page