Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
261 changes: 261 additions & 0 deletions benchmark_sample.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,261 @@
{
"machine_info": {
"node": "pkrvmccyg1gnepe",
"processor": "x86_64",
"machine": "x86_64",
"python_compiler": "GCC 13.3.0",
"python_implementation": "CPython",
"python_implementation_version": "3.12.3",
"python_version": "3.12.3",
"python_build": [
"main",
"Aug 14 2025 17:47:21"
],
"release": "6.11.0-1018-azure",
"system": "Linux",
"cpu": {
"python_version": "3.12.3.final.0 (64 bit)",
"cpuinfo_version": [
9,
0,
0
],
"cpuinfo_version_string": "9.0.0",
"arch": "X86_64",
"bits": 64,
"count": 4,
"arch_string_raw": "x86_64",
"vendor_id_raw": "AuthenticAMD",
"brand_raw": "AMD EPYC 7763 64-Core Processor",
"hz_advertised_friendly": "3.2409 GHz",
"hz_actual_friendly": "3.2409 GHz",
"hz_advertised": [
3240884000,
0
],
"hz_actual": [
3240884000,
0
],
"stepping": 1,
"model": 1,
"family": 25,
"flags": [
"3dnowext",
"3dnowprefetch",
"abm",
"adx",
"aes",
"aperfmperf",
"apic",
"arat",
"avx",
"avx2",
"bmi1",
"bmi2",
"clflush",
"clflushopt",
"clwb",
"clzero",
"cmov",
"cmp_legacy",
"constant_tsc",
"cpuid",
"cr8_legacy",
"cx16",
"cx8",
"de",
"decodeassists",
"erms",
"extd_apicid",
"f16c",
"flushbyasid",
"fma",
"fpu",
"fsgsbase",
"fsrm",
"fxsr",
"fxsr_opt",
"ht",
"hypervisor",
"invpcid",
"lahf_lm",
"lm",
"mca",
"mce",
"misalignsse",
"mmx",
"mmxext",
"movbe",
"msr",
"mtrr",
"nonstop_tsc",
"nopl",
"npt",
"nrip_save",
"nx",
"osvw",
"osxsave",
"pae",
"pat",
"pausefilter",
"pcid",
"pclmulqdq",
"pdpe1gb",
"pfthreshold",
"pge",
"pni",
"popcnt",
"pse",
"pse36",
"rdpid",
"rdpru",
"rdrand",
"rdrnd",
"rdseed",
"rdtscp",
"rep_good",
"sep",
"sha",
"sha_ni",
"smap",
"smep",
"sse",
"sse2",
"sse4_1",
"sse4_2",
"sse4a",
"ssse3",
"svm",
"syscall",
"topoext",
"tsc",
"tsc_known_freq",
"tsc_reliable",
"tsc_scale",
"umip",
"user_shstk",
"v_vmsave_vmload",
"vaes",
"vmcb_clean",
"vme",
"vmmcall",
"vpclmulqdq",
"xgetbv1",
"xsave",
"xsavec",
"xsaveerptr",
"xsaveopt",
"xsaves"
],
"l3_cache_size": 524288,
"l2_cache_size": 1048576,
"l1_data_cache_size": 65536,
"l1_instruction_cache_size": 65536,
"l2_cache_line_size": 512,
"l2_cache_associativity": 6
}
},
"commit_info": {
"id": "afd8571f32ddd9c4046f35d44be5d0f2f1c9463a",
"time": "2025-08-22T23:55:10Z",
"author_time": "2025-08-22T23:55:10Z",
"dirty": true,
"project": "stock-indicators-python",
"branch": "copilot/fix-392"
},
"benchmarks": [
{
"group": null,
"name": "test_benchmark_rsi",
"fullname": "benchmarks/test_benchmark_indicators.py::TestPerformance::test_benchmark_rsi",
"params": null,
"param": null,
"extra_info": {},
"options": {
"disable_gc": false,
"timer": "perf_counter",
"min_rounds": 5,
"max_time": 1.0,
"min_time": 5e-06,
"warmup": false
},
"stats": {
"min": 0.004117928999960441,
"max": 0.013795678999997563,
"mean": 0.0047654412641540975,
"stddev": 0.0016516754227122268,
"rounds": 53,
"median": 0.00432412300000351,
"iqr": 0.0003096714999770711,
"q1": 0.004292769750009029,
"q3": 0.0046024412499861,
"iqr_outliers": 5,
"stddev_outliers": 2,
"outliers": "2;5",
"ld15iqr": 0.004117928999960441,
"hd15iqr": 0.0050827120000462855,
"ops": 209.84415599076905,
"total": 0.25256838700016715,
"data": [
0.004580091999969227,
0.004422116999990067,
0.013795678999997563,
0.004366281999978128,
0.004225759999997081,
0.004235747999985051,
0.004223445000036463,
0.004206474000000071,
0.011844792999966103,
0.0045093900000097165,
0.004313873999990392,
0.004351004000000103,
0.004283387000043604,
0.0042905910000285985,
0.004296802999988358,
0.004322300000012547,
0.004293496000002506,
0.004338329999995949,
0.004311410000013893,
0.004333369999983461,
0.004312050000010004,
0.004320806999999149,
0.0043358959999864055,
0.0043086640000069565,
0.004302082000037899,
0.00432412300000351,
0.004307621999998901,
0.004326467999987926,
0.004293646000007811,
0.004287755999996534,
0.0042568480000113595,
0.005241398000009667,
0.00427911999997832,
0.004302371999983734,
0.006015285000046333,
0.004374427000016112,
0.004283697999994729,
0.0050827120000462855,
0.004117928999960441,
0.0041739819999975225,
0.004212424999991526,
0.004307622999988325,
0.004365762000020368,
0.004572388000042338,
0.004558742000028815,
0.0046694890000367195,
0.004747805000022254,
0.004778744000020652,
0.004727838000007978,
0.004700225999954455,
0.0047361030000274695,
0.004718600999979117,
0.004681410999978652
],
"iterations": 1
}
}
],
"datetime": "2025-08-29T00:19:11.069407+00:00",
"version": "5.1.0"
}
70 changes: 70 additions & 0 deletions benchmarks/test_decimal_conversion_performance.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
"""Benchmarks comparing performance of different decimal conversion methods."""

import pytest
from stock_indicators._cstypes import Decimal as CsDecimal
from stock_indicators._cstypes.decimal import to_pydecimal, to_pydecimal_via_double


@pytest.mark.performance
class TestDecimalConversionPerformance:
"""Benchmark performance of different decimal conversion methods."""

def test_benchmark_string_conversion(self, benchmark, raw_data):
"""Benchmark the current string-based conversion method."""
from stock_indicators._cstypes.decimal import to_pydecimal

raw_data = raw_data * 100 # Use subset for faster testing

# Pre-convert to CsDecimal to isolate the conversion performance
cs_decimals = [CsDecimal(row[2]) for row in raw_data]

def convert_via_string(cs_decimals):
for cs_decimal in cs_decimals:
to_pydecimal(cs_decimal)

benchmark(convert_via_string, cs_decimals)

def test_benchmark_double_conversion(self, benchmark, raw_data):
"""Benchmark the new double-based conversion method."""
from stock_indicators._cstypes.decimal import to_pydecimal_via_double

raw_data = raw_data * 100 # Use subset for faster testing

# Pre-convert to CsDecimal to isolate the conversion performance
cs_decimals = [CsDecimal(row[2]) for row in raw_data]

def convert_via_double(cs_decimals):
for cs_decimal in cs_decimals:
to_pydecimal_via_double(cs_decimal)

benchmark(convert_via_double, cs_decimals)

def test_benchmark_small_dataset_string_conversion(self, benchmark):
"""Benchmark string conversion with a controlled small dataset."""
test_values = [
1996.1012, 123.456789, 0.123456789, 999999.999999,
0.000001, 1000000.0, 1.8e-05, 1.234e10
] * 1000 # Repeat to get meaningful measurements

cs_decimals = [CsDecimal(val) for val in test_values]

def convert_via_string(cs_decimals):
for cs_decimal in cs_decimals:
to_pydecimal(cs_decimal)

benchmark(convert_via_string, cs_decimals)

def test_benchmark_small_dataset_double_conversion(self, benchmark):
"""Benchmark double conversion with a controlled small dataset."""
test_values = [
1996.1012, 123.456789, 0.123456789, 999999.999999,
0.000001, 1000000.0, 1.8e-05, 1.234e10
] * 1000 # Repeat to get meaningful measurements

cs_decimals = [CsDecimal(val) for val in test_values]

def convert_via_double(cs_decimals):
for cs_decimal in cs_decimals:
to_pydecimal_via_double(cs_decimal)

benchmark(convert_via_double, cs_decimals)
Loading
Loading