Skip to content

measure (and maybe show) speed of sabctools? #167

@sanderjo

Description

@sanderjo

Hi @Safihre and @mnightingale

Is this useful, or just nerdy: the speed of sabctools yenc (for reference: versus plain python).

Background: I did this because I'm experimenting with compiler and compiler options on RISC-V

CC=clang CXX=clang++ CXXFLAGS="-march=rva23u64_zbc" python3 setup.py build

and I wanted to know if (or: was hoping that) those options had impact on the resulting sactools speed.

On my x86_64 laptop:

sander@x360:~/git/sabctools$ venv/bin/python3 -m pytest tests/test_speed.py -s
================================================================================ test session starts =================================================================================
platform linux -- Python 3.13.7, pytest-9.0.2, pluggy-1.6.0
rootdir: /home/sander/git/sabctools
configfile: pytest.ini
collected 2 items                                                                                                                                                                    

tests/test_speed.py 

file and version /home/sander/git/sabctools/venv/lib/python3.13/site-packages/sabctools/__init__.py --- 9.3.2
PlainPython: Executed in 0.0056 seconds
Sabctools  : Executed in 0.0006 seconds
.

file and version /home/sander/git/sabctools/venv/lib/python3.13/site-packages/sabctools/__init__.py --- 9.3.2
PlainPython: Executed in 0.0054 seconds
Sabctools  : Executed in 0.0005 seconds
.

================================================================================= 2 passed in 0.06s ==================================================================================
sander@x360:~/git/sabctools$ 

with tests/test_speed.py just a copy of first part tests/test_decoder.py with extra logging:

import io
import os
import sys

import time

import pytest
import glob
from tests.testsupport import *


@pytest.mark.parametrize(
    "filename",
    ["test_regular.yenc", "test_regular_2.yenc"],
)
def test_regular(filename: str):
    data_plain = read_plain_yenc_file(filename)
    
    print(f"\n\nfile and version {sabctools.__file__} --- {sabctools.version}")
    
    start_time = time.perf_counter()
    res_python_yenc = python_yenc(data_plain)
    end_time = time.perf_counter()
    print(f"PlainPython: Executed in {end_time - start_time:.4f} seconds")

    start_time = time.perf_counter()
    #res2 = python_yenc(data_plain)
    res_sabctools_yenc_wrapper = sabctools_yenc_wrapper(data_plain)
    end_time = time.perf_counter()
    print(f"Sabctools  : Executed in {end_time - start_time:.4f} seconds")
    
    assert res_python_yenc == res_sabctools_yenc_wrapper
    #assert python_yenc(data_plain) == sabctools_yenc_wrapper(data_plain)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions