Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reduce calls to malloc in unordered_multiset #93

Merged
merged 2 commits into from
Aug 14, 2020

Conversation

bkthomps
Copy link
Owner

@bkthomps bkthomps commented Aug 14, 2020

Using this as a test:

    unordered_multiset me = unordered_multiset_init(sizeof(int), hash_int, compare_int);
    int count = 0;
    int i;
    for (i = 0; i < 1000000; i++) {
        unordered_multiset_put(me, &i);
    }
    for (i = 0; i < 1000000; i++) {
        count += unordered_multiset_contains(me, &i);
    }
    printf("%d\n", count);
    unordered_multiset_destroy(me);

The new version ran in 0.31s and the old version in 0.51s, which improves efficiency by 40%.

@bkthomps bkthomps added the efficiency Any improvement which can be made to the time or memory usage label Aug 14, 2020
@bkthomps bkthomps self-assigned this Aug 14, 2020
@bkthomps bkthomps merged commit 1154334 into master Aug 14, 2020
@bkthomps bkthomps deleted the reduce-malloc-unordered-multiset branch August 14, 2020 03:51
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
efficiency Any improvement which can be made to the time or memory usage
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant