Benchmark.js を試用してみた

1
think49 @think49

jsPerf は benchmark.js で動作していたのか。/ JavaScript関係のツールまとめてみた | Web scratch http://t.co/Ebopocw8 #JavaScript

2012-01-04 16:57:19
think49 @think49

@think49 Benchmark.js ( http://t.co/8SjQ6xiO ) と benchmark.js ( http://t.co/SaXVyBtf ) がHITするけど jsPerf で使用しているのはどっちだろう?

2012-01-04 17:01:20
think49 @think49

@think49 http://t.co/hg5aRdU2 には "benchmark.js" と書かれているので迷った。 http://t.co/BOmtNrcV からは http://t.co/8SjQ6xiO にリンクされているから Benchmark.js みたいだ。

2012-01-04 17:04:44
think49 @think49

さて試してみよう、と思い立ったところで躓く。http://t.co/8SjQ6xiO のどこから "benchmark.js" をダウンロードすればいいんだ…。#JavaScript

2012-01-04 17:14:53
think49 @think49

@think49 Googleでサイト検索してみるも3ページしかない。http://t.co/SOM4mIkr unit tests http://t.co/WyZXe5BN のソースから http://t.co/ofS3iyEh を突き止めてダウンロードできた。

2012-01-04 17:19:02
think49 @think49

@think49 ああ、ファイル名は "benchmark.js" なのか。

2012-01-04 17:22:14
think49 @think49

@think49 benchmarks.js のJSDoc流コメントには Benchmark.js <http://t.co/8SjQ6xiO>; とあるので Benchmark.js が正式名称で間違いなさそう。

2012-01-04 17:26:45
think49 @think49

Benchmark.js を試用中。this に new Benchmark が配列で格納されているようだけど、this[0].times 辺りの読み方がよくわからない。 http://t.co/3r2nvfEC のドキュメントを読むしかないか…。(日本語資料がほとんどない)

2012-01-04 17:48:41
think49 @think49

Benchmark#times.cycle: 最後のサイクル(secs)を完成するためにかかる時間。 http://t.co/4p7eqAE8

2012-01-04 17:52:26
think49 @think49

Benchmark#times.elapsed: ベンチマーク(secs)を完了するためにかかる時間。 http://t.co/0jaYPif4

2012-01-04 17:53:19
think49 @think49

Benchmark#times.period: テストを一回実行するためにかかる時間(secs)。 http://t.co/PgOvb0E4

2012-01-04 17:54:29
think49 @think49

Benchmark#times.timeStamp: ベンチマークが(ms)を始めた時のタイム・スタンプ。 http://t.co/c0FTfqAp

2012-01-04 17:55:45
小倉唯 @Constellation

Bencmark.js, varianceも測ってくれるので, なかなか素晴らしいですよ.

2012-01-04 17:58:31
think49 @think49

以上、OCN機械翻訳にて和訳。

2012-01-04 18:09:28
think49 @think49

速度比較をする場合は Benchmark#times.period で比較すれば良さそう。 benchmark.js のコードを読んでみたけどおそらく times.period = times.elapsed (ベンチマーク全体の完了時間) / count (テストの実行回数);

2012-01-04 18:11:37
think49 @think49

つまり、Benchmark#times.period は厳密には「テストを一回実行するためにかかる平均時間(secs)」となる。

2012-01-04 18:12:42
think49 @think49

Benchmark.js の公式ドキュメントが簡素すぎるてコード読まないと詳しい仕様がわからないっていうのが少し困る感じ。

2012-01-04 18:16:50
think49 @think49

@Constellation おそらく、Benchmark#stats.variance http://t.co/FgU1s7fm のことかと思いますが、まだ使い方がよくわかっていません…。 公式文書にサンプルコードでもあれば使い方の想像がつくのですが…。

2012-01-04 18:24:04
小倉唯 @Constellation

@think49 標準偏差ですー. 自分は昨日こんな感じで書いて使ってましたー. http://t.co/mc3DWYqq

2012-01-04 18:48:01
think49 @think49

@Constellation ありがとうございます。数値のバラツキ度合いを表す指標のようですね。使いこなせるかなー…。

2012-01-04 19:38:44