-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
2.1.0 - CLI Tool, Benchmarks, Dynamic Methods, and more!
- Added some new methods to SteemAsync - `get_witness` - Get data for a given witness name - `get_witness_list` - Get the ordered witness list (i.e. top 20) including their metadata - `wrapped_call` - Easier way to call condenser_api/database_api prefixed methods. Primarily used by getattr to handle dynamic methods. - Added `__getattr__` to `SteemAsync` to allow for dynamically generated methods - e.g. calling `SteemAsync().lookup_account_names(["someguy123", true])` will be transparently converted into `.wrapped_call('lookup_account_names', ["someguy123", true])` - allowing users to call same-named RPC methods just like a fully implemented method, instead of having to use `json_call` or `api_call` - Added `privex.steem.cli` and `__main__` - which allows using steem-async straight from the CLI, which can be helpful for developers/node admins who need to check if a specific method is working properly, or to check what it outputs. It can also be used for shellscripting and other uses. - Added `privex.steem.benchmarks` - which contains `bench_async` (steem-async benchmark) and `bench_beem` (beem benchmark), to allow developers to see and verify the performance difference between beem and steem-async. - Added `rich` to setup.py + Pipfile, as well as the `bench` extra to setup.py - Added info to the README about using the new CLI tool, as well as the benchmarks - Probably some other stuff too :)
- Loading branch information
1 parent
e6db58f
commit 6ee69f3
Showing
12 changed files
with
915 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
privex/steem/benchmarks |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
from privex.steem.cli import cli_main | ||
|
||
if __name__ == '__main__': | ||
cli_main() | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,114 @@ | ||
# Benchmark Comparison Tools | ||
|
||
This folder contains small scripts which benchmark `steem-async` as well as alternative steem/hive libraries, using simple | ||
benchmark tasks, such as loading 1000 blocks, reading account information, etc. | ||
|
||
This README contains results of some/all of the benchmarks that were ran on Someguy123's iMac Pro, using Python 3.9 | ||
and his home internet connection. | ||
|
||
## Results | ||
|
||
### Loading 1000 blocks with `beem` | ||
|
||
```sh | ||
chris | ~/steem-async/benchmarks $ ./bench_beem.py | ||
|
||
[2021-09-30 06:01:27.600455] Loading last 1000 blocks using beem ... | ||
|
||
[2021-09-30 06:03:36.533510] Total blocks: 1001 | ||
|
||
Start Time: 1632981687.6005 seconds | ||
End Time: 1632981816.5335 seconds | ||
|
||
Total Time: 128.9330 seconds | ||
``` | ||
|
||
### Loading 1000 blocks with `steem-async` | ||
|
||
```sh | ||
chris | ~/steem-async/benchmarks $ ./bench_async.py | ||
|
||
[2021-09-30 06:07:52.741749] Loading last 1000 blocks using steem-async ... | ||
|
||
[2021-09-30 06:08:10.053123] Total blocks: 1000 | ||
|
||
Start Time: 1632982072.7419 seconds | ||
End Time: 1632982090.0531 seconds | ||
|
||
Total Time: 17.3112 seconds | ||
``` | ||
|
||
## How to run the benchmarks | ||
|
||
### Option 1. - Use the benchmarks via the PyPi package | ||
|
||
This is the easiest method, as it doesn't require cloning the repo or setting up a virtualenv. | ||
|
||
Simply install the package `steem-async[bench]` using pip - which will install the steem-async library, | ||
with the `bench` extra requirements - which are the optional extra packages you need, to be able to run | ||
all of the benchmarks. | ||
|
||
```sh | ||
python3.9 -m pip install -U 'steem-async[bench]' | ||
# Alternatively - if you can't use pip via python3.x -m pip, then you can use 'pip3' instead. | ||
pip3 install -U 'steem-async[bench]' | ||
``` | ||
|
||
Now you should be able to call the benchmarks via the full module path: | ||
|
||
```sh | ||
# Run the steem-async 1000 block benchmark | ||
python3.9 -m privex.steem.benchmarks.bench_async | ||
# Run the beem 1000 block benchmark | ||
python3.9 -m privex.steem.benchmarks.bench_beem | ||
``` | ||
|
||
### Option 2. - Clone the repo and setup a dev environment | ||
|
||
First, clone the repo: | ||
|
||
```sh | ||
git clone https://github.com/Privex/steem-async.git | ||
cd steem-async | ||
``` | ||
|
||
Now install the dependencies + create a virtualenv using `pipenv` : | ||
|
||
```sh | ||
# If you don't already have pipenv installed - then you'll need to install it using pip | ||
python3.9 -m pip install -U pipenv | ||
|
||
# Install the main deps + create the virtualenv | ||
pipenv install | ||
|
||
# Now install the development deps, which should include the dependencies for running the benchmark | ||
pipenv install --dev | ||
``` | ||
|
||
Finally, enter the virtualenv using `pipenv shell` , and run the benchmarks using either `python3.x -m` , | ||
or cd into the folder and execute them `./bench_async.py` | ||
|
||
```sh | ||
# Activate the virtualenv | ||
pipenv shell | ||
|
||
### | ||
# Run the benchmarks using python's module runner: | ||
### | ||
|
||
# Run the steem-async 1000 block benchmark | ||
python3 -m benchmarks.bench_async | ||
# Run the beem 1000 block benchmark | ||
python3 -m benchmarks.bench_beem | ||
|
||
### | ||
# Alternatively, you can run the benchmarks as individual files | ||
### | ||
cd benchmarks | ||
# Run the steem-async 1000 block benchmark | ||
./bench_async.py | ||
# Run the beem 1000 block benchmark | ||
./bench_beem.py | ||
``` | ||
|
||
|
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
#!/usr/bin/env python3 | ||
from datetime import datetime | ||
from privex.steem import SteemAsync | ||
from privex.helpers import dec_round | ||
from decimal import Decimal | ||
from privex.helpers import env_csv, env_int | ||
import time | ||
import asyncio | ||
import logging | ||
|
||
try: | ||
from rich import print | ||
except ImportError: | ||
pass | ||
|
||
log = logging.getLogger('privex.steem') | ||
log.setLevel(logging.ERROR) | ||
|
||
|
||
SECS_NS = Decimal('1000000000') | ||
|
||
HIVE_NODES = env_csv('HIVE_NODES', ['https://direct.hived.privex.io', 'https://anyx.io', 'https://api.deathwing.me']) | ||
BATCH_SIZE = env_int('BATCH_SIZE', 100) | ||
NUM_BLOCKS = env_int('NUM_BLOCKS', 1000) | ||
|
||
|
||
async def main(): | ||
ss = SteemAsync(HIVE_NODES) | ||
ss.config_set('batch_size', BATCH_SIZE) | ||
print(f"\n [{datetime.utcnow()!s}] Loading last {NUM_BLOCKS} blocks using steem-async ... \n\n") | ||
start_time = time.time_ns() | ||
blks = await ss.get_blocks(-NUM_BLOCKS) | ||
end_time = time.time_ns() | ||
print(f"\n [{datetime.utcnow()!s}] Total blocks:", len(blks), "\n") | ||
start_time, end_time = Decimal(start_time), Decimal(end_time) | ||
start_secs = start_time / SECS_NS | ||
end_secs = end_time / SECS_NS | ||
print("Start Time:", dec_round(start_secs, 4), "seconds") | ||
print("End Time:", dec_round(end_secs, 4), "seconds\n") | ||
print("Total Time:", dec_round(end_secs - start_secs, 4), "seconds\n") | ||
|
||
|
||
if __name__ == '__main__': | ||
asyncio.run(main()) |
Oops, something went wrong.