當前位置: 首頁>>代碼示例>>Python>>正文


Python Stopwatch.read方法代碼示例

本文整理匯總了Python中stopwatch.Stopwatch.read方法的典型用法代碼示例。如果您正苦於以下問題:Python Stopwatch.read方法的具體用法?Python Stopwatch.read怎麽用?Python Stopwatch.read使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在stopwatch.Stopwatch的用法示例。


在下文中一共展示了Stopwatch.read方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test_largescale

# 需要導入模塊: from stopwatch import Stopwatch [as 別名]
# 或者: from stopwatch.Stopwatch import read [as 別名]
def test_largescale():
    s = Stopwatch()
    integration_factor = 5
    device_map = device_parser.build_device_map(device_parser.parse_data('test.xml'))
    test_size = 10000
    histogram = OrderedDict()
    
    for i in range(5):
        time = 0.0

        for j in range(5):
            s.start()
            generate_test_input(device_map, test_size, file_name='test_input1.csv')
            s.stop()
            print('Generating test input of size {}: '.format(test_size), s.read())
        
            s.reset()
            s.start()
            analyze_data_nograph('csvs/test_input1.csv', integration_factor, device_map)
            s.stop()
            print('Processing input of size {}:     '.format(test_size), s.read())

            time += s.read()
            s.reset()
            
        print('Average time for input of size {}:  '.format(test_size), time/5)
        histogram[test_size] = time/5
        
        test_size *= 2

    print(histogram)
    
    for i,j in histogram.items():
        print(' size | time ')
        print('{0:5d}|{1:5f}'.format(i,j))
開發者ID:ksegarra,項目名稱:PLSim,代碼行數:37,代碼來源:sim_test.py

示例2: evaluate

# 需要導入模塊: from stopwatch import Stopwatch [as 別名]
# 或者: from stopwatch.Stopwatch import read [as 別名]
 def evaluate(self,times=None):
     results = []
     s = Stopwatch()
     times = times if times != None else self._times
     for i in range(times):
         self._setup()
         s.reset()
         gc.disable()
         s.start()
         self._code()
         gc.enable()
         results.append(s.read())
     self._evaluate_results = [(min(results),sum(results)/times,max(results))] + [results]
     return self._evaluate_results
開發者ID:dblam,項目名稱:Duy-s-Python-Projects,代碼行數:16,代碼來源:performance.py

示例3: Stopwatch

# 需要導入模塊: from stopwatch import Stopwatch [as 別名]
# 或者: from stopwatch.Stopwatch import read [as 別名]
import prompt
from  stopwatch import Stopwatch


original_number = prompt.for_int('Enter a positive number', is_legal=(lambda x : x > 0))
is_debugging    = prompt.for_bool('Display intermediate results',True)
cycle_count     = 1
test_number     = original_number

timer = Stopwatch(running_now = True)

while True:
    if is_debugging:
        print('Cycle', cycle_count, ': test number is now', test_number)
    
    ####################
    if test_number == 1:
        break;
    ####################

    cycle_count += 1
    if test_number % 2 == 0:
        test_number = test_number // 2
    else:
        test_number = 3*test_number + 1

timer.stop()

print('\n\nFor test number =',original_number,'cycles to 1 =',cycle_count)
print('Process took', timer.read(), 'seconds')
開發者ID:shwilliams,項目名稱:ICS33,代碼行數:32,代碼來源:collatz.py

示例4: while

# 需要導入模塊: from stopwatch import Stopwatch [as 別名]
# 或者: from stopwatch.Stopwatch import read [as 別名]
    elif first_roll == 2 or first_roll == 3 or first_roll == 12:
        lose_count += 1                      #Lose on the first roll with 2, 3, or 12

    else:                                    #Try to make the point as the game continues
        point = first_roll                   #point will never store 7, 11, 2, 3, or 12

        while(True):                         #Roll until roll point (win) or 7 (lose)
            roll = dice.roll().pip_sum()

            if roll == point:                #If made the point first
                win_count += 1               #...win and this game is over
                break
            elif roll == 7:                  #If roll a 7 first
                lose_count+= 1               #...lose and this game is over
                break
game_timer.stop();


##Display Statistics

print('  Raw Wins/Lose =', '{:,}'.format(win_count), '/', '{:,}'.format(lose_count))
print('  % Wins/Lose   =', 100.0*win_count/(win_count+lose_count), '/', 100.0*lose_count/(win_count+lose_count))
print()

print('  Dice Thrown   =', '{:,}'.format(dice.rolls()))
print('  Avg Dice/game =', dice.rolls()/games_to_play)
print()

print('  Elapsed Time  =' , game_timer.read(), 'seconds')
print('  Speed         =', '{:,}'.format(int(games_to_play/game_timer.read())), 'games/second')
開發者ID:shwilliams,項目名稱:ICS33,代碼行數:32,代碼來源:craps.py


注:本文中的stopwatch.Stopwatch.read方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。