annotate Looping.st @ 8:30da8c1da4d4 >>178

SmalltalkやScalar版のベンチマークを追加。
author "uncorrelated zombie" <uncorrelated@yahoo.co.jp>
date Fri, 18 Feb 2011 19:58:26 +0900
parents 861b93741d60
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
5
861b93741d60 id:sumim氏のSmalltalk版とRuby版のコードを追加。
"uncorrelated zombie" <uncorrelated@yahoo.co.jp>
parents:
diff changeset
1 'From Squeak4.2 of 4 February 2011 [latest update: #10966] on 17 February 2011 at 8:44:09 am'!
861b93741d60 id:sumim氏のSmalltalk版とRuby版のコードを追加。
"uncorrelated zombie" <uncorrelated@yahoo.co.jp>
parents:
diff changeset
2 Object subclass: #Looping
861b93741d60 id:sumim氏のSmalltalk版とRuby版のコードを追加。
"uncorrelated zombie" <uncorrelated@yahoo.co.jp>
parents:
diff changeset
3 instanceVariableNames: 'n0'
861b93741d60 id:sumim氏のSmalltalk版とRuby版のコードを追加。
"uncorrelated zombie" <uncorrelated@yahoo.co.jp>
parents:
diff changeset
4 classVariableNames: ''
861b93741d60 id:sumim氏のSmalltalk版とRuby版のコードを追加。
"uncorrelated zombie" <uncorrelated@yahoo.co.jp>
parents:
diff changeset
5 poolDictionaries: ''
861b93741d60 id:sumim氏のSmalltalk版とRuby版のコードを追加。
"uncorrelated zombie" <uncorrelated@yahoo.co.jp>
parents:
diff changeset
6 category: 'Benchmark-Looping'!
861b93741d60 id:sumim氏のSmalltalk版とRuby版のコードを追加。
"uncorrelated zombie" <uncorrelated@yahoo.co.jp>
parents:
diff changeset
7
861b93741d60 id:sumim氏のSmalltalk版とRuby版のコードを追加。
"uncorrelated zombie" <uncorrelated@yahoo.co.jp>
parents:
diff changeset
8 !Looping methodsFor: 'calculation' stamp: 'sumim 2/17/2011 00:17'!
861b93741d60 id:sumim氏のSmalltalk版とRuby版のコードを追加。
"uncorrelated zombie" <uncorrelated@yahoo.co.jp>
parents:
diff changeset
9 calc: n
861b93741d60 id:sumim氏のSmalltalk版とRuby版のコードを追加。
"uncorrelated zombie" <uncorrelated@yahoo.co.jp>
parents:
diff changeset
10 | n1 |
861b93741d60 id:sumim氏のSmalltalk版とRuby版のコードを追加。
"uncorrelated zombie" <uncorrelated@yahoo.co.jp>
parents:
diff changeset
11 n1 := n0 + (1 - (2 * (n \\ 2))).
861b93741d60 id:sumim氏のSmalltalk版とRuby版のコードを追加。
"uncorrelated zombie" <uncorrelated@yahoo.co.jp>
parents:
diff changeset
12 n0 := n.
861b93741d60 id:sumim氏のSmalltalk版とRuby版のコードを追加。
"uncorrelated zombie" <uncorrelated@yahoo.co.jp>
parents:
diff changeset
13 ^n1! !
861b93741d60 id:sumim氏のSmalltalk版とRuby版のコードを追加。
"uncorrelated zombie" <uncorrelated@yahoo.co.jp>
parents:
diff changeset
14
861b93741d60 id:sumim氏のSmalltalk版とRuby版のコードを追加。
"uncorrelated zombie" <uncorrelated@yahoo.co.jp>
parents:
diff changeset
15 !Looping methodsFor: 'initializing' stamp: 'sumim 2/16/2011 23:59'!
861b93741d60 id:sumim氏のSmalltalk版とRuby版のコードを追加。
"uncorrelated zombie" <uncorrelated@yahoo.co.jp>
parents:
diff changeset
16 initialize
861b93741d60 id:sumim氏のSmalltalk版とRuby版のコードを追加。
"uncorrelated zombie" <uncorrelated@yahoo.co.jp>
parents:
diff changeset
17 n0 := 0! !
861b93741d60 id:sumim氏のSmalltalk版とRuby版のコードを追加。
"uncorrelated zombie" <uncorrelated@yahoo.co.jp>
parents:
diff changeset
18
861b93741d60 id:sumim氏のSmalltalk版とRuby版のコードを追加。
"uncorrelated zombie" <uncorrelated@yahoo.co.jp>
parents:
diff changeset
19
861b93741d60 id:sumim氏のSmalltalk版とRuby版のコードを追加。
"uncorrelated zombie" <uncorrelated@yahoo.co.jp>
parents:
diff changeset
20 !Looping class methodsFor: 'benchmark' stamp: 'sumim 2/17/2011 00:52'!
861b93741d60 id:sumim氏のSmalltalk版とRuby版のコードを追加。
"uncorrelated zombie" <uncorrelated@yahoo.co.jp>
parents:
diff changeset
21 benchmark
861b93741d60 id:sumim氏のSmalltalk版とRuby版のコードを追加。
"uncorrelated zombie" <uncorrelated@yahoo.co.jp>
parents:
diff changeset
22 "self benchmark"
861b93741d60 id:sumim氏のSmalltalk版とRuby版のコードを追加。
"uncorrelated zombie" <uncorrelated@yahoo.co.jp>
parents:
diff changeset
23 | l n t1 t2 |
861b93741d60 id:sumim氏のSmalltalk版とRuby版のコードを追加。
"uncorrelated zombie" <uncorrelated@yahoo.co.jp>
parents:
diff changeset
24 l := Looping new.
861b93741d60 id:sumim氏のSmalltalk版とRuby版のコードを追加。
"uncorrelated zombie" <uncorrelated@yahoo.co.jp>
parents:
diff changeset
25 n := 1.
861b93741d60 id:sumim氏のSmalltalk版とRuby版のコードを追加。
"uncorrelated zombie" <uncorrelated@yahoo.co.jp>
parents:
diff changeset
26 t1 := Time millisecondClockValue.
861b93741d60 id:sumim氏のSmalltalk版とRuby版のコードを追加。
"uncorrelated zombie" <uncorrelated@yahoo.co.jp>
parents:
diff changeset
27 2147483647 timesRepeat: [
861b93741d60 id:sumim氏のSmalltalk版とRuby版のコードを追加。
"uncorrelated zombie" <uncorrelated@yahoo.co.jp>
parents:
diff changeset
28 n := l calc: n
861b93741d60 id:sumim氏のSmalltalk版とRuby版のコードを追加。
"uncorrelated zombie" <uncorrelated@yahoo.co.jp>
parents:
diff changeset
29 ].
861b93741d60 id:sumim氏のSmalltalk版とRuby版のコードを追加。
"uncorrelated zombie" <uncorrelated@yahoo.co.jp>
parents:
diff changeset
30 t2 := Time millisecondClockValue.
861b93741d60 id:sumim氏のSmalltalk版とRuby版のコードを追加。
"uncorrelated zombie" <uncorrelated@yahoo.co.jp>
parents:
diff changeset
31 Transcript cr; show: n printString.
861b93741d60 id:sumim氏のSmalltalk版とRuby版のコードを追加。
"uncorrelated zombie" <uncorrelated@yahoo.co.jp>
parents:
diff changeset
32 Transcript cr; show: 'Smalltalk'; tab; show: (t2 - t1 / 1000.0) printString! !
861b93741d60 id:sumim氏のSmalltalk版とRuby版のコードを追加。
"uncorrelated zombie" <uncorrelated@yahoo.co.jp>
parents:
diff changeset
33
861b93741d60 id:sumim氏のSmalltalk版とRuby版のコードを追加。
"uncorrelated zombie" <uncorrelated@yahoo.co.jp>
parents:
diff changeset
34 Looping benchmark!
861b93741d60 id:sumim氏のSmalltalk版とRuby版のコードを追加。
"uncorrelated zombie" <uncorrelated@yahoo.co.jp>
parents:
diff changeset
35