Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/arrmansa/fast-fizzbuzz-python
FizzBuzz implementation in python that outputs to pv > /dev/null.
https://github.com/arrmansa/fast-fizzbuzz-python
fizz-buzz fizzbuzz fizzbuzz-python
Last synced: about 1 month ago
JSON representation
FizzBuzz implementation in python that outputs to pv > /dev/null.
- Host: GitHub
- URL: https://github.com/arrmansa/fast-fizzbuzz-python
- Owner: arrmansa
- License: apache-2.0
- Created: 2022-04-16T22:10:44.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2022-04-25T19:36:33.000Z (over 2 years ago)
- Last Synced: 2023-08-31T07:03:44.762Z (over 1 year ago)
- Topics: fizz-buzz, fizzbuzz, fizzbuzz-python
- Language: Python
- Homepage:
- Size: 28.3 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Fast-FizzBuzz-python
For https://codegolf.stackexchange.com/questions/215216/high-throughput-fizz-buzz/. Do check out the awesome submissions by others and the benchmark code is here if you want to run it on your machine https://github.com/omertuc/fizzgolf.
## Usage on google colab
Change the output number (1e9 for < 2 min runtime) (1e8 for <20 s runtime)### fizzbuzz_numpy_os.py and fizzbuzz_pure_python.py
!apt-get install pv
!python3 fizzbuzz_numpy_os.py | pv > /dev/null
or
!python3 fizzbuzz_pure_python.py | pv > /dev/null### fizzbuzz_multiprocessing_numpy_os.py and fizzbuzz_multiprocessing_numpy_os_improvised_lock.py
#install python 3.9
!sudo apt-get update -y
!sudo apt-get install python3.9#change alternatives
!sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.7 1
!sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.9 2#check python version
!python --version#Pip
!apt-get install python3-pip
!apt install python3.9-distutils
!python3 -m pip install --upgrade pip
!pip install numpy
!apt-get install pv
!python3 fizzbuzz_multiprocessing_numpy_os.py | pv > /dev/null## Performance on google collab, length = int(1e9)
!python3 fizzbuzz_numpy_os.py | pv > /dev/null #chunk 8100
7.33GiB 0:00:59 [ 125MiB/s] [ <=> ]
!python3 fizzbuzz_pure_python.py | pv > /dev/null #chunk 6000
7.33GiB 0:01:25 [87.5MiB/s] [ <=> ]
!python3 fizzbuzz_multiprocessing_numpy_os.py | pv > /dev/null #chunk 1500000
7.34GiB 0:01:27 [85.7MiB/s] [ <=> ]!python3 fizzbuzz_multiprocessing_numpy_os_improvised_lock.py | pv > /dev/null #chunk 1500000
7.34GiB 0:01:14 [ 100MiB/s] [ <=> ]## Notes
fizzbuzz_multiprocessing_numpy_os.py is slow on colab because of the overhead from making new processes.
If there were more cores and with larger strings it might be possible to overcome this.