Revision 8f5bbad392b904d1f5b7e9f4ee262f339d999056 authored by Damian Sawicki on 13 June 2024, 08:41:41 UTC, committed by Dylan Reimerink on 15 June 2024, 08:22:04 UTC
This commit adds alternative implementations of methods of ImmSet:
 * InsertNew(xs ...T)
 * DeleteNew(xs ...T)
 * UnionNew(s2 ImmSet[T])
 * DifferenceNew(s2 ImmSet[T])
and benchmarks these implementations agains the existing ones.

Benchmarking results:
 * for Insert, the proposed method becomes faster already with the
   container of size 1000, and then it performed 10x faster for size
   10,000 and 100x faster for size 100,000;
 * for Delete, the proposed method becomes faster already with the
   container of size 1000, and then it performed ~5x faster for size
   10,000;
 * for Difference, the proposed method was already 4x faster for size
   100, and then it performed 7x faster for size 1000, 35x times faster
   for size 10,000, and 193x faster for size 100,000;
 * for Union, the proposed method performs slightly faster, but gains
   do not visibly grow with increasing size.

Theoretically, the proposed solutions have improved computational
complexity:
 * the complexity of Insert is O(len(s.xs)*len(xs)), and the complexity
   of InsertNew is O(len(s.xs)+len(xs));
 * the complexity of Delete is O(len(s.xs)*len(xs)), and the complexity
   of DeleteNew is O(len(s.xs)+len(xs));
 * the complexity of Difference is O(len(s.xs)*len(s2.xs)) because it
   uses Delete internally, and the complexity of DifferenceNew
   O(len(s.xs)+len(s2.xs));
 * the complexity of Union is harder to estimate: it involves sorting a
   slice of size n=len(s.xs)+len(s2.xs), but this slice is a
   concatenation of two sorted slices, so most likely this does not lead
   to the usual O(n*log(n)) complexity; of course, it is at least O(n);
   the complexity of UnionNew is O(n).

Signed-off-by: Damian Sawicki <dsawicki@google.com>
1 parent 5aa52b0
History
File Mode Size
_exts
_static
_templates
bpf
cmdref
community
configuration
contributing
gettingstarted
images
installation
internals
network
observability
operations
overview
requirements-min
robots
security
.dockerignore -rw-r--r-- 69 bytes
.gitignore -rw-r--r-- 55 bytes
.readthedocs.yaml -rw-r--r-- 587 bytes
Dockerfile -rw-r--r-- 903 bytes
Makefile -rw-r--r-- 5.7 KB
_api l--------- 6 bytes
api.rst -rw-r--r-- 3.0 KB
beta.rst -rw-r--r-- 123 bytes
cheatsheet.rst -rw-r--r-- 9.5 KB
check-build.sh -rwxr-xr-x 5.8 KB
check-cmdref.sh -rwxr-xr-x 336 bytes
check-codeowners.sh -rwxr-xr-x 395 bytes
check-crd-compat-table.sh -rwxr-xr-x 7.3 KB
check-crdlist.sh -rwxr-xr-x 344 bytes
check-examples.sh -rwxr-xr-x 601 bytes
check-flaggen.sh -rwxr-xr-x 342 bytes
check-helmvalues.sh -rwxr-xr-x 353 bytes
check-links.sh -rwxr-xr-x 1.4 KB
codeowners.rst -rw-r--r-- 13.0 KB
conf.py -rw-r--r-- 10.1 KB
crdlist.rst -rw-r--r-- 634 bytes
further_reading.rst -rw-r--r-- 359 bytes
glossary.rst -rw-r--r-- 2.0 KB
grpcapi.rst -rw-r--r-- 587 bytes
helm-reference.rst -rw-r--r-- 384 bytes
helm-values.rst -rw-r--r-- 153.8 KB
helm-values.tmp.tmpl -rw-r--r-- 37 bytes
index.rst -rw-r--r-- 3.6 KB
kvstore.rst -rw-r--r-- 7.6 KB
requirements.txt -rw-r--r-- 1.6 KB
runtime.txt -rw-r--r-- 4 bytes
spelling_wordlist.txt -rw-r--r-- 6.7 KB
update-cmdref.sh -rwxr-xr-x 684 bytes
update-codeowners.sh -rwxr-xr-x 638 bytes
update-docs-builder-image.sh -rwxr-xr-x 625 bytes
update-spelling_wordlist.sh -rwxr-xr-x 354 bytes
yaml.config -rw-r--r-- 97 bytes

back to top