python test

Sql code posted by kojh
created at 07 Sep 02:01, updated at 21 Oct 04:37

Edit | Back
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#///////////////////////////////////////////////////////////////////////////////
def elapsed_time_fn (fn):    
    def inner(*args, **kwargs):
        start_time = perf_counter()
        to_execute = fn(*args, **kwargs)
        end_time = perf_counter()
        execution_time = end_time - start_time
        print('{0} : elapsed {1:.8f}s '.format(fn.__name__, execution_time))
        return to_execute
    return inner

#///////////////////////////////////////////////////////////////////////////////
def setenv_openblas_num_thread (): 
    cpu_core_cnt = "8" #  !!!  XXX 
    os.environ["OPENBLAS_NUM_THREADS"] = cpu_core_cnt
    os.environ["OMP_NUM_THREADS"]      = cpu_core_cnt
    os.environ["MKL_NUM_THREADS"]      = cpu_core_cnt
752 Bytes in 2 ms with coderay