Code Monkey home page Code Monkey logo

Comments (5)

greg7mdp avatar greg7mdp commented on August 26, 2024

Hi @steven-varga. To help me understand exactly what your use case is, can you post the declaration of the sparse_hash_map that you used?
I have the feeling that the memory used by the hash table to index the 6000 symbols is negligible in comparison of the data stored (the 6e7 count/day), which doesn't depend on the hash table implementation. Thanks!

from sparsepp.

steven-varga avatar steven-varga commented on August 26, 2024

Yes indeed: it is about speed as opposed to footprint.
spp::sparse_hash_map<std::string, uint64_t> map1; or spp::sparse_hash_map<uint64_t, uint64_t> map2;
Then I used auto it = map.find( key ); and inserted new ones upon failure.
The profiling showed the code path spends 50% on hash lookups, I tried a quick drop in, and didn't notice difference.

from sparsepp.

greg7mdp avatar greg7mdp commented on August 26, 2024

Ah, sparsepp is mostly about footprint, especially when inserting entries and resizing occurs (high water mark). Should be a little bit faster, though!

from sparsepp.

steven-varga avatar steven-varga commented on August 26, 2024

update: the attached pictures were identical, corrected mistake. The result is same runtime.
Profiling and runtime attached, done on: gcc (Ubuntu 5.4.0-6ubuntu1~16.04.5) 5.4.0 20160609: Intel(R) Core(TM) i7-3520M CPU @ 2.90GHz, runtime is near same, slight 1s difference when using std::map
hope it helps!

spp runtime
std unordered runtime
spp string long
spp profile

from sparsepp.

greg7mdp avatar greg7mdp commented on August 26, 2024

Hum, I don't know what to say here. The implementation of sparsepp require more copies (or move) of the hash table objects than a regular hash table, so for complex objects which are expensive to copy or move, sparsepp may not be the best alternative.

from sparsepp.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.