Package intelhex :: Module bench
[hide private]
[frames] | no frames]

Module bench

source code

Benchmarking.

Run each test 3 times and get median value. Using 10K array as base test time.

Each other test compared with base with next formula:

        Tc * Nb
   q = ---------
        Tb * Nc

Here:

* Tc - execution time of current test * Tb - execution time of base * Nb - array size of base (10K) * Nc - array size of current test

If resulting value is ``q <= 1.0`` it's the best possible result, i.e. time increase proportionally to array size.

Classes [hide private]
  Measure
Measure execution time helper.
Functions [hide private]
 
median(values)
Return median value for the list of values.
source code
 
run_test(func, fobj)
Run func with argument fobj and measure execution time.
source code
 
run_readtest_N_times(func, hexstr, n)
Run each test N times.
source code
 
run_writetest_N_times(func, n)
Run each test N times.
source code
 
time_coef(tc, nc, tb, nb)
Return time coefficient relative to base numbers.
source code
 
get_test_data(n1, offset, n2)
Create test data on given pattern.
source code
 
get_base_10K()
Base 10K
source code
 
get_100K() source code
 
get_100K_100K() source code
 
get_0_100K() source code
 
get_1M() source code
 
main(argv=None)
Main function to run benchmarks.
source code
Variables [hide private]
  HELP = 'Usage: python _bench.py [OPTIONS]\n\nOptions:\n -h ...
Function Details [hide private]

median(values)

source code 

Return median value for the list of values.

Parameters:
  • values - list of values for processing.
Returns:
median value.

run_test(func, fobj)

source code 

Run func with argument fobj and measure execution time.

Parameters:
  • func - function for test
  • fobj - data for test
Returns:
execution time

run_readtest_N_times(func, hexstr, n)

source code 

Run each test N times.

Parameters:
  • func - function for test
  • hexstr - string with content of hex file to read
  • n - times to repeat.
Returns:
(median time, times list)

run_writetest_N_times(func, n)

source code 

Run each test N times.

Parameters:
  • func - function for test
  • n - times to repeat.
Returns:
(median time, times list)

time_coef(tc, nc, tb, nb)

source code 

Return time coefficient relative to base numbers.

Parameters:
  • tc - current test time
  • nc - current test data size
  • tb - base test time
  • nb - base test data size
Returns:
time coef.

get_test_data(n1, offset, n2)

source code 

Create test data on given pattern.

Parameters:
  • n1 - size of first part of array at base address 0.
  • offset - offset for second part of array.
  • n2 - size of second part of array at given offset.
Returns:
(overall size, hex file, IntelHex object)

main(argv=None)

source code 

Main function to run benchmarks.

Parameters:
  • argv - command-line arguments.
Returns:
exit code (0 is OK).

Variables Details [hide private]

HELP

Value:
'''Usage: python _bench.py [OPTIONS]

Options:
    -h      this help
    -n N    repeat tests N times
    -r      run only tests for read operation
    -w      run only tests for write operation

...