Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
titleCode of the event loop in test-scaling-subproc.py
collapsetrue
def do_algo(cpu=0, cmt='v0'):

    hostname = get_hostname()
    #cpu_num = psutil.Process().cpu_num()
    print('requested cpu:%03d' % cpu)

    SAVE_FIGS = True
    SHOW_FIGS = False
    nevents = 100
    ntpoints = 6
    arrts = np.zeros((nevents,ntpoints), dtype=np.float64)
    t05_old = time()

    for nevt in range(nevents):
        t00 = time()
        times = time_consuming_algorithm()
        cpu_num = psutil.Process().cpu_num()
        #if cpu_num >=16 and cpu_num <=23:
        #    print('cpu_num:%03d nevt:%03d time:%.6f CPU_NUM IN WEKA RANGE [16,23]' % (cpu_num, nevt, dt_sec))
        t05 = time()
        times = (t00,) + times + (t05,)
        arrts[nevt,:] = times
        dt_evt = t05 - t05_old
        t05_old = t05
        if nevt%10>0: continue
        dt_alg = times[4] - times[3]
        dt_in  = times[4] - times[1]
        print('cpu_num:%03d nevt:%03d  times (sec)' % (cpu_num, nevt), \
             ' random arrs: %.6f' % (times[2] - times[1]), \
             ' indeces: %.6f'     % (times[3] - times[2]), \
             ' alg: %.6f'         % (times[4] - times[3]), \
             ' inside algo: %.6f' % (times[4] - times[1]), \
             ' per event: %.6f'   % dt_evt)
...
further code is ffor saving results and graphics

...