2012-05-07 6 views
1

すぐに新しいMacデスクトップを購入する予定で、CPU、RAM、またはハードドライブがスクリプトのボトルネックになっているかどうかを知りたい。RubyスクリプトでCPU、RAM、ハードドライブのボトルネックがあるかどうかを確認

私はUbuntuの12.04でのRuby 1.9.3と私のメインのユニットテストを実行し、以下の情報を得た:

$ date; /usr/bin/time --verbose ruby1.9.1 test/test_all.rb ; date 
Mon May 7 15:04:38 EST 2012 
Run options: 

# Running tests: 

[snip 705 dots] 

Finished tests in 50.672999s, 13.9127 tests/s, 49.1781 assertions/s. 

705 tests, 2492 assertions, 0 failures, 0 errors, 0 skips 
    Command being timed: "ruby1.9.1 test/test_all.rb" 
    User time (seconds): 29.25 
    System time (seconds): 5.26 
    Percent of CPU this job got: 67% 
    Elapsed (wall clock) time (h:mm:ss or m:ss): 0:51.01 
    Average shared text size (kbytes): 0 
    Average unshared data size (kbytes): 0 
    Average stack size (kbytes): 0 
    Average total size (kbytes): 0 
    Maximum resident set size (kbytes): 238592 
    Average resident set size (kbytes): 0 
    Major (requiring I/O) page faults: 0 
    Minor (reclaiming a frame) page faults: 4180160 
    Voluntary context switches: 31187 
    Involuntary context switches: 12397 
    Swaps: 0 
    File system inputs: 0 
    File system outputs: 224 
    Socket messages sent: 0 
    Socket messages received: 0 
    Signals delivered: 0 
    Page size (bytes): 4096 
    Exit status: 0 
Mon May 7 15:05:29 EST 2012 

User Plusのシステムにかかる時間は、ウォール時間未満であると、私はCPUのISNを仮定唯一のボトルネックです。ボトルネックは他に何ができるのでしょうか?

答えて

2

cachegrindツールvalgrind'sを使用すると、プログラムのメモリパフォーマンス(キャッシュをどれくらいうまく活用しているか)を分析できます。ディスクのパフォーマンスに関する

$ valgrind --tool=cachegrind ruby ./hello.rb 
==7082== Cachegrind, a cache and branch-prediction profiler. 
==7082== Copyright (C) 2002-2008, and GNU GPL'd, by Nicholas Nethercote et al. 
==7082== Using LibVEX rev 1884, a library for dynamic binary translation. 
==7082== Copyright (C) 2004-2008, and GNU GPL'd, by OpenWorks LLP. 
==7082== Using valgrind-3.4.1-Debian, a dynamic binary instrumentation framework. 
==7082== Copyright (C) 2000-2008, and GNU GPL'd, by Julian Seward et al. 
==7082== For more details, rerun with: -v 
==7082== 
hello world 
==7082== 
==7082== I refs:  14,529,000 
==7082== I1 misses:  24,856 
==7082== L2i misses:   6,707 
==7082== I1 miss rate:  0.17% 
==7082== L2i miss rate:  0.04% 
==7082== 
==7082== D refs:  7,110,663 (4,572,482 rd + 2,538,181 wr) 
==7082== D1 misses:  48,207 ( 33,427 rd + 14,780 wr) 
==7082== L2d misses:  16,350 ( 3,821 rd + 12,529 wr) 
==7082== D1 miss rate:  0.6% (  0.7%  +  0.5% ) 
==7082== L2d miss rate:  0.2% (  0.0%  +  0.4% ) 
==7082== 
==7082== L2 refs:   73,063 ( 58,283 rd + 14,780 wr) 
==7082== L2 misses:   23,057 ( 10,528 rd + 12,529 wr) 
==7082== L2 miss rate:   0.1% (  0.0%  +  0.4% ) 

、ノーディスク付きプログラムは/ IO使用量は、あなたのハードドライブがボトルネックの少なくとも一つであるかもしれないと信じて私をリードし、ユーザ時間でほぼ完全に実行するだろうと信じています。おそらく、プログラムのディスク使用量をプロファイリングするための良いツールをお勧めする人がいるでしょうか?

関連する問題