chrislo-sourceclassifier 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- data/Manifest +0 -312
- data/Rakefile +2 -2
- data/sourceclassifier.gemspec +6 -6
- metadata +4 -316
- data/sources/gcc/ackermann.gcc-2.gcc +0 -93
- data/sources/gcc/ackermann.gcc-3.gcc +0 -20
- data/sources/gcc/ary.gcc +0 -40
- data/sources/gcc/binarytrees.gcc +0 -136
- data/sources/gcc/binarytrees.gcc-2.gcc +0 -140
- data/sources/gcc/binarytrees.gcc-3.gcc +0 -134
- data/sources/gcc/chameneos.gcc +0 -117
- data/sources/gcc/chameneos.gcc-2.gcc +0 -134
- data/sources/gcc/chameneos.gcc-3.gcc +0 -120
- data/sources/gcc/chameneosredux.gcc +0 -306
- data/sources/gcc/echo.gcc +0 -144
- data/sources/gcc/except.gcc +0 -52
- data/sources/gcc/fannkuch.gcc +0 -105
- data/sources/gcc/fannkuch.gcc-2.gcc +0 -94
- data/sources/gcc/fasta.gcc +0 -158
- data/sources/gcc/fasta.gcc-2.gcc +0 -132
- data/sources/gcc/fasta.gcc-3.gcc +0 -145
- data/sources/gcc/fasta.gcc-4.gcc +0 -141
- data/sources/gcc/fibo.gcc +0 -20
- data/sources/gcc/harmonic.gcc +0 -22
- data/sources/gcc/hash.gcc +0 -31
- data/sources/gcc/hash2.gcc +0 -38
- data/sources/gcc/heapsort.gcc +0 -72
- data/sources/gcc/hello.gcc-2.gcc +0 -12
- data/sources/gcc/hello.gcc-3.gcc +0 -20
- data/sources/gcc/knucleotide.gcc +0 -173
- data/sources/gcc/knucleotide.gcc-2.gcc +0 -168
- data/sources/gcc/lists.gcc +0 -226
- data/sources/gcc/magicsquares.gcc +0 -378
- data/sources/gcc/mandelbrot.gcc +0 -84
- data/sources/gcc/mandelbrot.gcc-2.gcc +0 -63
- data/sources/gcc/mandelbrot.gcc-3.gcc +0 -91
- data/sources/gcc/mandelbrot.gcc-4.gcc +0 -78
- data/sources/gcc/matrix.gcc +0 -66
- data/sources/gcc/message.gcc-2.gcc +0 -72
- data/sources/gcc/message.gcc-3.gcc +0 -64
- data/sources/gcc/methcall.gcc +0 -89
- data/sources/gcc/moments.gcc +0 -120
- data/sources/gcc/nbody.gcc +0 -142
- data/sources/gcc/nbody.gcc-2.gcc +0 -143
- data/sources/gcc/nbody.gcc-3.gcc +0 -142
- data/sources/gcc/nestedloop.gcc +0 -25
- data/sources/gcc/nsieve.gcc +0 -35
- data/sources/gcc/nsievebits.gcc-2.gcc +0 -37
- data/sources/gcc/nsievebits.gcc-3.gcc +0 -53
- data/sources/gcc/objinst.gcc +0 -95
- data/sources/gcc/partialsums.gcc +0 -86
- data/sources/gcc/partialsums.gcc-3.gcc +0 -81
- data/sources/gcc/partialsums.gcc-4.gcc +0 -68
- data/sources/gcc/pidigits.gcc +0 -105
- data/sources/gcc/primes.gcc +0 -75
- data/sources/gcc/prodcons.gcc +0 -86
- data/sources/gcc/random.gcc +0 -29
- data/sources/gcc/raytracer.gcc +0 -125
- data/sources/gcc/raytracer.gcc-2.gcc +0 -181
- data/sources/gcc/recursive.gcc +0 -68
- data/sources/gcc/recursive.gcc-2.gcc +0 -55
- data/sources/gcc/regexdna.gcc-2.gcc +0 -126
- data/sources/gcc/regexmatch.gcc +0 -136
- data/sources/gcc/revcomp.gcc +0 -85
- data/sources/gcc/revcomp.gcc-2.gcc +0 -88
- data/sources/gcc/revcomp.gcc-4.gcc +0 -71
- data/sources/gcc/reversefile.gcc +0 -103
- data/sources/gcc/reversefile.gcc-2.gcc +0 -56
- data/sources/gcc/sieve.gcc +0 -34
- data/sources/gcc/spectralnorm.gcc +0 -54
- data/sources/gcc/spellcheck.gcc +0 -72
- data/sources/gcc/spellcheck.gcc-2.gcc +0 -61
- data/sources/gcc/strcat.gcc +0 -38
- data/sources/gcc/sumcol.gcc-2.gcc +0 -98
- data/sources/gcc/sumcol.gcc-3.gcc +0 -22
- data/sources/gcc/sumcol.gcc-4.gcc +0 -18
- data/sources/gcc/sumcol.gcc-5.gcc +0 -32
- data/sources/gcc/takfp.gcc +0 -23
- data/sources/gcc/tcp-stream.gcc +0 -122
- data/sources/gcc/tcpecho.gcc +0 -122
- data/sources/gcc/tcpecho.gcc-2.gcc +0 -136
- data/sources/gcc/tcprequest.gcc +0 -122
- data/sources/gcc/threadring.gcc +0 -73
- data/sources/gcc/wc.gcc +0 -52
- data/sources/gcc/wc.gcc-2.gcc +0 -40
- data/sources/gcc/wc.gcc-3.gcc +0 -46
- data/sources/gcc/wordfreq.gcc-2.gcc +0 -85
- data/sources/perl/ackermann.perl +0 -28
- data/sources/perl/ackermann.perl-2.perl +0 -25
- data/sources/perl/ackermann.perl-3.perl +0 -20
- data/sources/perl/ackermann.perl-4.perl +0 -18
- data/sources/perl/ary.perl +0 -25
- data/sources/perl/ary.perl-2.perl +0 -23
- data/sources/perl/binarytrees.perl +0 -66
- data/sources/perl/binarytrees.perl-2.perl +0 -71
- data/sources/perl/chameneos.perl +0 -67
- data/sources/perl/echo.perl +0 -81
- data/sources/perl/except.perl +0 -73
- data/sources/perl/fannkuch.perl +0 -44
- data/sources/perl/fannkuch.perl-2.perl +0 -38
- data/sources/perl/fasta.perl +0 -112
- data/sources/perl/fasta.perl-2.perl +0 -135
- data/sources/perl/fasta.perl-4.perl +0 -122
- data/sources/perl/fibo.perl +0 -15
- data/sources/perl/fibo.perl-2.perl +0 -0
- data/sources/perl/fibo.perl-3.perl +0 -0
- data/sources/perl/harmonic.perl +0 -7
- data/sources/perl/hash.perl +0 -23
- data/sources/perl/hash.perl-2.perl +0 -17
- data/sources/perl/hash.perl-3.perl +0 -24
- data/sources/perl/hash2.perl +0 -16
- data/sources/perl/heapsort.perl +0 -65
- data/sources/perl/heapsort.perl-2.perl +0 -0
- data/sources/perl/hello.perl +0 -5
- data/sources/perl/knucleotide.perl-2.perl +0 -30
- data/sources/perl/lists.perl +0 -48
- data/sources/perl/mandelbrot.perl-2.perl +0 -32
- data/sources/perl/matrix.perl +0 -59
- data/sources/perl/matrix.perl-2.perl +0 -0
- data/sources/perl/matrix.perl-3.perl +0 -0
- data/sources/perl/message.perl +0 -27
- data/sources/perl/methcall.perl +0 -66
- data/sources/perl/moments.perl +0 -44
- data/sources/perl/nbody.perl +0 -108
- data/sources/perl/nestedloop.perl +0 -28
- data/sources/perl/nsieve.perl-2.perl +0 -41
- data/sources/perl/nsieve.perl-4.perl +0 -43
- data/sources/perl/nsievebits.perl +0 -37
- data/sources/perl/objinst.perl +0 -73
- data/sources/perl/partialsums.perl-3.perl +0 -31
- data/sources/perl/pidigits.perl +0 -52
- data/sources/perl/pidigits.perl-2.perl +0 -47
- data/sources/perl/process.perl +0 -50
- data/sources/perl/prodcons.perl +0 -47
- data/sources/perl/random.perl-4.perl +0 -17
- data/sources/perl/recursive.perl-2.perl +0 -57
- data/sources/perl/regexdna.perl +0 -48
- data/sources/perl/regexdna.perl-2.perl +0 -43
- data/sources/perl/regexdna.perl-3.perl +0 -50
- data/sources/perl/regexdna.perl-4.perl +0 -49
- data/sources/perl/regexdna.perl-5.perl +0 -42
- data/sources/perl/regexdna.perl-6.perl +0 -43
- data/sources/perl/regexmatch.perl +0 -35
- data/sources/perl/revcomp.perl-2.perl +0 -34
- data/sources/perl/reversefile.perl +0 -8
- data/sources/perl/reversefile.perl-2.perl +0 -0
- data/sources/perl/reversefile.perl-3.perl +0 -0
- data/sources/perl/sieve.perl +0 -23
- data/sources/perl/spectralnorm.perl-2.perl +0 -54
- data/sources/perl/spellcheck.perl +0 -24
- data/sources/perl/strcat.perl +0 -13
- data/sources/perl/strcat.perl-2.perl +0 -0
- data/sources/perl/sumcol.perl +0 -8
- data/sources/perl/takfp.perl +0 -23
- data/sources/perl/takfp.perl-3.perl +0 -20
- data/sources/perl/tcpecho.perl +0 -61
- data/sources/perl/tcprequest.perl +0 -61
- data/sources/perl/tcpstream.perl +0 -61
- data/sources/perl/threadring.perl +0 -55
- data/sources/perl/threadring.perl-2.perl +0 -43
- data/sources/perl/wc.perl +0 -20
- data/sources/perl/wc.perl-2.perl +0 -14
- data/sources/perl/wordfreq.perl +0 -22
- data/sources/perl/wordfreq.perl-3.perl +0 -0
- data/sources/perl/wordfreq.perl3.perl +0 -0
- data/sources/python/ackermann.python +0 -21
- data/sources/python/ary.python +0 -19
- data/sources/python/binarytrees.python +0 -39
- data/sources/python/binarytrees.python-3.python +0 -44
- data/sources/python/chameneos.python-6.python +0 -73
- data/sources/python/chameneosredux.python +0 -126
- data/sources/python/chameneosredux.python-2.python +0 -122
- data/sources/python/dispatch.python +0 -176
- data/sources/python/dispatch.python-2.python +0 -136
- data/sources/python/echo.python +0 -64
- data/sources/python/except.python +0 -62
- data/sources/python/fannkuch.python +0 -50
- data/sources/python/fannkuch.python-2.python +0 -54
- data/sources/python/fasta.python-2.python +0 -79
- data/sources/python/fibo.python +0 -17
- data/sources/python/fibo.python-2.python +0 -0
- data/sources/python/fibo.python-3.python +0 -0
- data/sources/python/harmonic.python-2.python +0 -9
- data/sources/python/hash.python +0 -21
- data/sources/python/hash.python-2.python +0 -0
- data/sources/python/hash2.python +0 -30
- data/sources/python/heapsort.python-3.python +0 -66
- data/sources/python/hello.python +0 -5
- data/sources/python/implicitode.python +0 -231
- data/sources/python/knucleotide.python +0 -55
- data/sources/python/lists.python +0 -44
- data/sources/python/magicsquares.python +0 -145
- data/sources/python/mandelbrot.python +0 -44
- data/sources/python/mandelbrot.python-2.python +0 -35
- data/sources/python/mandelbrot.python-3.python +0 -46
- data/sources/python/matrix.python +0 -34
- data/sources/python/matrix.python-2.python +0 -23
- data/sources/python/message.python +0 -24
- data/sources/python/message.python-2.python +0 -20
- data/sources/python/message.python-3.python +0 -19
- data/sources/python/meteor.python +0 -210
- data/sources/python/meteor.python-2.python +0 -192
- data/sources/python/methcall.python +0 -51
- data/sources/python/moments.python +0 -65
- data/sources/python/nbody.python +0 -123
- data/sources/python/nbody.python-2.python +0 -120
- data/sources/python/nestedloop.python +0 -24
- data/sources/python/nsieve.python +0 -27
- data/sources/python/nsieve.python-2.python +0 -23
- data/sources/python/nsieve.python-4.python +0 -25
- data/sources/python/nsievebits.python +0 -27
- data/sources/python/nsievebits.python-2.python +0 -43
- data/sources/python/objinst.python +0 -53
- data/sources/python/partialsums.python +0 -37
- data/sources/python/partialsums.python-2.python +0 -35
- data/sources/python/partialsums.python-3.python +0 -48
- data/sources/python/pidigits.python +0 -38
- data/sources/python/pidigits.python-3.python +0 -63
- data/sources/python/pidigits.python-4.python +0 -24
- data/sources/python/process.python +0 -51
- data/sources/python/process.python-2.python +0 -133
- data/sources/python/prodcons.python +0 -51
- data/sources/python/prodcons.python-2.python +0 -0
- data/sources/python/random.python +0 -27
- data/sources/python/raytracer.python +0 -203
- data/sources/python/recursive.python +0 -35
- data/sources/python/regexdna.python +0 -39
- data/sources/python/regexdna.python-2.python +0 -34
- data/sources/python/regexmatch.python +0 -36
- data/sources/python/revcomp.python-3.python +0 -31
- data/sources/python/reversefile.python +0 -13
- data/sources/python/reversefile.python-2.python +0 -0
- data/sources/python/reversefile.python-3.python +0 -0
- data/sources/python/sieve.python +0 -50
- data/sources/python/spectralnorm.python-2.python +0 -36
- data/sources/python/spellcheck.python +0 -17
- data/sources/python/strcat.python +0 -35
- data/sources/python/strcat.python-2.python +0 -0
- data/sources/python/sumcol.python-2.python +0 -0
- data/sources/python/sumcol.python-3.python +0 -0
- data/sources/python/takfp.python +0 -19
- data/sources/python/tcpecho.python +0 -67
- data/sources/python/tcprequest.python +0 -67
- data/sources/python/tcpstream.python +0 -67
- data/sources/python/threadring.python +0 -47
- data/sources/python/threadring.python-2.python +0 -40
- data/sources/python/threadring.python-3.python +0 -34
- data/sources/python/wc.python-2.python +0 -19
- data/sources/python/wordfreq.python +0 -43
- data/sources/python/wordfreq.python-2.python +0 -0
- data/sources/python/wordfreq.python-3.python +0 -28
- data/sources/python/wordfreq.python-4.python +0 -38
- data/sources/python/wordfreq.python-5.python +0 -39
- data/sources/ruby/ackermann.ruby +0 -17
- data/sources/ruby/ackermann.ruby-5.ruby +0 -153
- data/sources/ruby/ary.ruby +0 -22
- data/sources/ruby/binarytrees.ruby-2.ruby +0 -55
- data/sources/ruby/chameneos.ruby-2.ruby +0 -71
- data/sources/ruby/dispatch.ruby +0 -114
- data/sources/ruby/echo.ruby +0 -41
- data/sources/ruby/except.ruby +0 -61
- data/sources/ruby/except.ruby-2.ruby +0 -61
- data/sources/ruby/fannkuch.ruby +0 -42
- data/sources/ruby/fasta.ruby +0 -81
- data/sources/ruby/fibo.ruby +0 -15
- data/sources/ruby/harmonic.ruby-2.ruby +0 -15
- data/sources/ruby/hash.ruby +0 -19
- data/sources/ruby/hash2.ruby +0 -23
- data/sources/ruby/heapsort.ruby +0 -55
- data/sources/ruby/hello.ruby +0 -6
- data/sources/ruby/knucleotide.ruby-2.ruby +0 -44
- data/sources/ruby/lists.ruby +0 -46
- data/sources/ruby/mandelbrot.ruby-3.ruby +0 -63
- data/sources/ruby/matrix.ruby +0 -40
- data/sources/ruby/matrix.ruby-2.ruby +0 -30
- data/sources/ruby/message.ruby +0 -29
- data/sources/ruby/message.ruby-2.ruby +0 -24
- data/sources/ruby/meteor.ruby +0 -386
- data/sources/ruby/meteor.ruby-2.ruby +0 -561
- data/sources/ruby/methcall.ruby +0 -58
- data/sources/ruby/methcall.ruby-2.ruby +0 -54
- data/sources/ruby/moments.ruby +0 -64
- data/sources/ruby/nbody.ruby-2.ruby +0 -145
- data/sources/ruby/nestedloop.ruby +0 -22
- data/sources/ruby/nsieve.ruby +0 -36
- data/sources/ruby/nsieve.ruby-2.ruby +0 -25
- data/sources/ruby/nsievebits.ruby-2.ruby +0 -42
- data/sources/ruby/objinst.ruby +0 -58
- data/sources/ruby/partialsums.ruby +0 -39
- data/sources/ruby/pidigits.ruby +0 -92
- data/sources/ruby/pidigits.ruby-2.ruby +0 -109
- data/sources/ruby/prodcons.ruby +0 -41
- data/sources/ruby/random.ruby +0 -17
- data/sources/ruby/recursive.ruby-2.ruby +0 -53
- data/sources/ruby/regexdna.ruby +0 -32
- data/sources/ruby/regexdna.ruby-2.ruby +0 -38
- data/sources/ruby/regexmatch.ruby +0 -33
- data/sources/ruby/revcomp.ruby +0 -28
- data/sources/ruby/reversefile.ruby +0 -7
- data/sources/ruby/sieve.ruby +0 -30
- data/sources/ruby/spectralnorm.ruby +0 -48
- data/sources/ruby/spellcheck.ruby +0 -18
- data/sources/ruby/spellcheck.ruby-2.ruby +0 -0
- data/sources/ruby/strcat.ruby +0 -12
- data/sources/ruby/strcat.ruby-2.ruby +0 -12
- data/sources/ruby/sumcol.ruby +0 -12
- data/sources/ruby/sumcol.ruby-2.ruby +0 -5
- data/sources/ruby/takfp.ruby +0 -15
- data/sources/ruby/tcpecho.ruby +0 -45
- data/sources/ruby/tcprequest.ruby +0 -45
- data/sources/ruby/tcpstream.ruby +0 -45
- data/sources/ruby/threadring.ruby +0 -61
- data/sources/ruby/threadring.ruby-2.ruby +0 -33
- data/sources/ruby/wc.ruby +0 -15
- data/sources/ruby/wordfreq.ruby +0 -17
- data/sources/ruby/wordfreq.ruby2.ruby +0 -0
@@ -1,93 +0,0 @@
|
|
1
|
-
/* -*- mode: c -*-
|
2
|
-
* $Id: ackermann.gcc-2.gcc,v 1.1 2005-03-15 06:17:49 bfulgham Exp $
|
3
|
-
* http://shootout.alioth.debian.org/
|
4
|
-
*
|
5
|
-
* Modified to use C inline and unroll of recursive functions
|
6
|
-
* by Paul Hsieh
|
7
|
-
*/
|
8
|
-
|
9
|
-
#include <stdio.h>
|
10
|
-
#include <stdlib.h>
|
11
|
-
#include <limits.h>
|
12
|
-
#if (defined(__linux) || defined(__unix) || defined(__GNUC__))
|
13
|
-
#include <unistd.h>
|
14
|
-
#elif (defined(WIN32) || defined(_WIN32) || defined(__WIN32) ||
|
15
|
-
defined(_WINDOWS) || defined(_WINDOWS_))
|
16
|
-
#include <windows.h>
|
17
|
-
#endif
|
18
|
-
|
19
|
-
#define glueAckExpand(m) Ack##m
|
20
|
-
#define glueAck(m) glueAckExpand(m)
|
21
|
-
|
22
|
-
#define Ack0(N) ((N)+1)
|
23
|
-
|
24
|
-
#define AckDecl(M,M1) \
|
25
|
-
static int glueAck(M) (int N) { \
|
26
|
-
if (0 == N) return glueAck(M1) (1); \
|
27
|
-
if (1 == N) return glueAck(M1) (glueAck(M1) (1)); \
|
28
|
-
return glueAck(M1) (glueAck(M) (N-1)); \
|
29
|
-
}
|
30
|
-
|
31
|
-
AckDecl(1,0)
|
32
|
-
AckDecl(2,1)
|
33
|
-
AckDecl(3,2)
|
34
|
-
AckDecl(4,3)
|
35
|
-
|
36
|
-
/* Removes the overhead of passing around and M parameter,
|
37
|
-
when it is low (which is the only way this can actually
|
38
|
-
complete execution.) */
|
39
|
-
|
40
|
-
int Ack (int M, int N) {
|
41
|
-
switch (M) {
|
42
|
-
case 0: return Ack0 (N);
|
43
|
-
case 1: return Ack1 (N);
|
44
|
-
case 2: return Ack2 (N);
|
45
|
-
case 3: return Ack3 (N);
|
46
|
-
case 4: return Ack4 (N);
|
47
|
-
}
|
48
|
-
|
49
|
-
if (0 == N) return Ack (M-1, 1);
|
50
|
-
if (1 == N) return Ack (M-1, Ack (M-1, 1));
|
51
|
-
return Ack (M-1, Ack (M, N-1));
|
52
|
-
}
|
53
|
-
|
54
|
-
/* Not called. Uses full mathematical simplfications when
|
55
|
-
its possible and unravells the recursion on the N
|
56
|
-
parameter into a for() loop (so the stack level never
|
57
|
-
goes deeper than O(M)). */
|
58
|
-
|
59
|
-
int AckCheat (int M, int N) {
|
60
|
-
switch (M) {
|
61
|
-
case 0: return Ack0 (N);
|
62
|
-
case 1: return N + 2;
|
63
|
-
case 2: return 2*N + 3;
|
64
|
-
case 3: if (N < (CHAR_BIT * sizeof(int) - 3))
|
65
|
-
return (1 << (N+3))-3;
|
66
|
-
}
|
67
|
-
|
68
|
-
if (0 == N) return AckCheat (M-1, 1);
|
69
|
-
if (1 == N) return AckCheat (M-1, AckCheat (M-1, 1));
|
70
|
-
|
71
|
-
{
|
72
|
-
int a = AckCheat (M-1, 1);
|
73
|
-
for (;N; N--) a = AckCheat (M-1, a);
|
74
|
-
return a;
|
75
|
-
}
|
76
|
-
}
|
77
|
-
|
78
|
-
int main(int argc, char *argv[]) {
|
79
|
-
int m = ((argc >= 3) ? atoi(argv[argc-2]) : 3);
|
80
|
-
int n = ((argc >= 2) ? atoi(argv[argc-1]) : 1);
|
81
|
-
|
82
|
-
printf("Ack(%d,%d): %d\n", m, n, Ack (m, n));
|
83
|
-
|
84
|
-
/* sleep long enough so we can measure memory usage */
|
85
|
-
#if (defined(__linux) || defined(__unix) || defined(__GNUC__))
|
86
|
-
sleep(1);
|
87
|
-
#elif (defined(WIN32) || defined(_WIN32) || defined(__WIN32) ||
|
88
|
-
defined(_WINDOWS) || defined(_WINDOWS_))
|
89
|
-
Sleep(1000);
|
90
|
-
#endif
|
91
|
-
|
92
|
-
return(0);
|
93
|
-
}
|
@@ -1,20 +0,0 @@
|
|
1
|
-
/* -*- mode: c -*-
|
2
|
-
* $Id: ackermann.gcc-3.gcc,v 1.1 2005-04-27 05:21:30 igouy-guest Exp $
|
3
|
-
* http://www.bagley.org/~doug/shootout/
|
4
|
-
*
|
5
|
-
* modified by Isaac Gouy
|
6
|
-
*/
|
7
|
-
|
8
|
-
#include <stdio.h>
|
9
|
-
#include <stdlib.h>
|
10
|
-
#include <unistd.h>
|
11
|
-
|
12
|
-
int Ack(int M, int N) { return(M ? (Ack(M-1,N ? Ack(M,(N-1)) : 1)) : N+1); }
|
13
|
-
|
14
|
-
int main(int argc, char *argv[]) {
|
15
|
-
int n = ((argc == 2) ? atoi(argv[1]) : 1);
|
16
|
-
|
17
|
-
printf("Ack(3,%d): %d\n", n, Ack(3, n));
|
18
|
-
return(0);
|
19
|
-
}
|
20
|
-
|
data/sources/gcc/ary.gcc
DELETED
@@ -1,40 +0,0 @@
|
|
1
|
-
/* -*- mode: c -*-
|
2
|
-
* $Id: ary.gcc,v 1.2 2004-05-22 07:25:00 bfulgham Exp $
|
3
|
-
* http://www.bagley.org/~doug/shootout/
|
4
|
-
*
|
5
|
-
* this program is modified from:
|
6
|
-
* http://cm.bell-labs.com/cm/cs/who/bwk/interps/pap.html
|
7
|
-
* Timing Trials, or, the Trials of Timing: Experiments with Scripting
|
8
|
-
* and User-Interface Languages</a> by Brian W. Kernighan and
|
9
|
-
* Christopher J. Van Wyk.
|
10
|
-
*
|
11
|
-
* I added free() to deallocate memory.
|
12
|
-
*/
|
13
|
-
|
14
|
-
#include <stdio.h>
|
15
|
-
#include <stdlib.h>
|
16
|
-
|
17
|
-
int
|
18
|
-
main(int argc, char *argv[]) {
|
19
|
-
int n = ((argc == 2) ? atoi(argv[1]) : 1);
|
20
|
-
int i, k, *x, *y;
|
21
|
-
|
22
|
-
x = (int *) calloc(n, sizeof(int));
|
23
|
-
y = (int *) calloc(n, sizeof(int));
|
24
|
-
|
25
|
-
for (i = 0; i < n; i++) {
|
26
|
-
x[i] = i + 1;
|
27
|
-
}
|
28
|
-
for (k=0; k<1000; k++) {
|
29
|
-
for (i = n-1; i >= 0; i--) {
|
30
|
-
y[i] += x[i];
|
31
|
-
}
|
32
|
-
}
|
33
|
-
|
34
|
-
fprintf(stdout, "%d %d\n", y[0], y[n-1]);
|
35
|
-
|
36
|
-
free(x);
|
37
|
-
free(y);
|
38
|
-
|
39
|
-
return(0);
|
40
|
-
}
|
data/sources/gcc/binarytrees.gcc
DELETED
@@ -1,136 +0,0 @@
|
|
1
|
-
/* The Computer Language Shootout Benchmarks
|
2
|
-
http://shootout.alioth.debian.org/
|
3
|
-
|
4
|
-
contributed by Kevin Carson
|
5
|
-
compilation:
|
6
|
-
gcc -O3 -fomit-frame-pointer -funroll-loops -static binary-trees.c -lm
|
7
|
-
icc -O3 -ip -unroll -static binary-trees.c -lm
|
8
|
-
*/
|
9
|
-
|
10
|
-
#include <malloc.h>
|
11
|
-
#include <math.h>
|
12
|
-
#include <stdio.h>
|
13
|
-
#include <stdlib.h>
|
14
|
-
|
15
|
-
|
16
|
-
typedef struct tn {
|
17
|
-
struct tn* left;
|
18
|
-
struct tn* right;
|
19
|
-
long item;
|
20
|
-
} treeNode;
|
21
|
-
|
22
|
-
|
23
|
-
treeNode* NewTreeNode(treeNode* left, treeNode* right, long item)
|
24
|
-
{
|
25
|
-
treeNode* new;
|
26
|
-
|
27
|
-
new = (treeNode*)malloc(sizeof(treeNode));
|
28
|
-
|
29
|
-
new->left = left;
|
30
|
-
new->right = right;
|
31
|
-
new->item = item;
|
32
|
-
|
33
|
-
return new;
|
34
|
-
} /* NewTreeNode() */
|
35
|
-
|
36
|
-
|
37
|
-
long ItemCheck(treeNode* tree)
|
38
|
-
{
|
39
|
-
if (tree->left == NULL)
|
40
|
-
return tree->item;
|
41
|
-
else
|
42
|
-
return tree->item + ItemCheck(tree->left) - ItemCheck(tree->right);
|
43
|
-
} /* ItemCheck() */
|
44
|
-
|
45
|
-
|
46
|
-
treeNode* BottomUpTree(long item, unsigned depth)
|
47
|
-
{
|
48
|
-
if (depth > 0)
|
49
|
-
return NewTreeNode
|
50
|
-
(
|
51
|
-
BottomUpTree(2 * item - 1, depth - 1),
|
52
|
-
BottomUpTree(2 * item, depth - 1),
|
53
|
-
item
|
54
|
-
);
|
55
|
-
else
|
56
|
-
return NewTreeNode(NULL, NULL, item);
|
57
|
-
} /* BottomUpTree() */
|
58
|
-
|
59
|
-
|
60
|
-
void DeleteTree(treeNode* tree)
|
61
|
-
{
|
62
|
-
if (tree->left != NULL)
|
63
|
-
{
|
64
|
-
DeleteTree(tree->left);
|
65
|
-
DeleteTree(tree->right);
|
66
|
-
}
|
67
|
-
|
68
|
-
free(tree);
|
69
|
-
} /* DeleteTree() */
|
70
|
-
|
71
|
-
|
72
|
-
int main(int argc, char* argv[])
|
73
|
-
{
|
74
|
-
unsigned N, depth, minDepth, maxDepth, stretchDepth;
|
75
|
-
treeNode *stretchTree, *longLivedTree, *tempTree;
|
76
|
-
|
77
|
-
N = atol(argv[1]);
|
78
|
-
|
79
|
-
minDepth = 4;
|
80
|
-
|
81
|
-
if ((minDepth + 2) > N)
|
82
|
-
maxDepth = minDepth + 2;
|
83
|
-
else
|
84
|
-
maxDepth = N;
|
85
|
-
|
86
|
-
stretchDepth = maxDepth + 1;
|
87
|
-
|
88
|
-
stretchTree = BottomUpTree(0, stretchDepth);
|
89
|
-
printf
|
90
|
-
(
|
91
|
-
"stretch tree of depth %u\t check: %li\n",
|
92
|
-
stretchDepth,
|
93
|
-
ItemCheck(stretchTree)
|
94
|
-
);
|
95
|
-
|
96
|
-
DeleteTree(stretchTree);
|
97
|
-
|
98
|
-
longLivedTree = BottomUpTree(0, maxDepth);
|
99
|
-
|
100
|
-
for (depth = minDepth; depth <= maxDepth; depth += 2)
|
101
|
-
{
|
102
|
-
long i, iterations, check;
|
103
|
-
|
104
|
-
iterations = pow(2, maxDepth - depth + minDepth);
|
105
|
-
|
106
|
-
check = 0;
|
107
|
-
|
108
|
-
for (i = 1; i <= iterations; i++)
|
109
|
-
{
|
110
|
-
tempTree = BottomUpTree(i, depth);
|
111
|
-
check += ItemCheck(tempTree);
|
112
|
-
DeleteTree(tempTree);
|
113
|
-
|
114
|
-
tempTree = BottomUpTree(-i, depth);
|
115
|
-
check += ItemCheck(tempTree);
|
116
|
-
DeleteTree(tempTree);
|
117
|
-
} /* for(i = 1...) */
|
118
|
-
|
119
|
-
printf
|
120
|
-
(
|
121
|
-
"%li\t trees of depth %u\t check: %li\n",
|
122
|
-
iterations * 2,
|
123
|
-
depth,
|
124
|
-
check
|
125
|
-
);
|
126
|
-
} /* for(depth = minDepth...) */
|
127
|
-
|
128
|
-
printf
|
129
|
-
(
|
130
|
-
"long lived tree of depth %u\t check: %li\n",
|
131
|
-
maxDepth,
|
132
|
-
ItemCheck(longLivedTree)
|
133
|
-
);
|
134
|
-
|
135
|
-
return 0;
|
136
|
-
} /* main() */
|
@@ -1,140 +0,0 @@
|
|
1
|
-
/* The Computer Language Shootout Benchmarks
|
2
|
-
http://shootout.alioth.debian.org/
|
3
|
-
|
4
|
-
contributed by Benoit Hudson based on a contribution of Kevin Carson
|
5
|
-
compilation:
|
6
|
-
gcc -O3 -fomit-frame-pointer binary-trees-2.c
|
7
|
-
*/
|
8
|
-
|
9
|
-
#include <stdlib.h>
|
10
|
-
#include <stdio.h>
|
11
|
-
|
12
|
-
typedef struct tn {
|
13
|
-
struct tn* left;
|
14
|
-
struct tn* right;
|
15
|
-
long item;
|
16
|
-
} treeNode;
|
17
|
-
|
18
|
-
static treeNode *freelist = 0;
|
19
|
-
|
20
|
-
treeNode* NewTreeNode(treeNode* left, treeNode* right, long item)
|
21
|
-
{
|
22
|
-
treeNode* new;
|
23
|
-
|
24
|
-
if (NULL == freelist) {
|
25
|
-
new = (treeNode*)malloc(sizeof(treeNode));
|
26
|
-
} else {
|
27
|
-
new = freelist;
|
28
|
-
freelist = freelist -> left;
|
29
|
-
}
|
30
|
-
|
31
|
-
new->left = left;
|
32
|
-
new->right = right;
|
33
|
-
new->item = item;
|
34
|
-
|
35
|
-
return new;
|
36
|
-
} /* NewTreeNode() */
|
37
|
-
|
38
|
-
|
39
|
-
long ItemCheck(treeNode* tree)
|
40
|
-
{
|
41
|
-
if (tree->left == NULL)
|
42
|
-
return tree->item;
|
43
|
-
else
|
44
|
-
return tree->item + ItemCheck(tree->left) - ItemCheck(tree->right);
|
45
|
-
} /* ItemCheck() */
|
46
|
-
|
47
|
-
|
48
|
-
treeNode* BottomUpTree(long item, unsigned depth)
|
49
|
-
{
|
50
|
-
if (depth > 0)
|
51
|
-
return NewTreeNode
|
52
|
-
(
|
53
|
-
BottomUpTree(2 * item - 1, depth - 1),
|
54
|
-
BottomUpTree(2 * item, depth - 1),
|
55
|
-
item
|
56
|
-
);
|
57
|
-
else
|
58
|
-
return NewTreeNode(NULL, NULL, item);
|
59
|
-
} /* BottomUpTree() */
|
60
|
-
|
61
|
-
|
62
|
-
void DeleteTree(treeNode* tree)
|
63
|
-
{
|
64
|
-
if (tree->left != NULL)
|
65
|
-
{
|
66
|
-
DeleteTree(tree->left);
|
67
|
-
DeleteTree(tree->right);
|
68
|
-
}
|
69
|
-
|
70
|
-
tree -> left = freelist;
|
71
|
-
freelist = tree;
|
72
|
-
} /* DeleteTree() */
|
73
|
-
|
74
|
-
|
75
|
-
int main(int argc, char* argv[])
|
76
|
-
{
|
77
|
-
unsigned N, depth, minDepth, maxDepth, stretchDepth;
|
78
|
-
treeNode *stretchTree, *longLivedTree, *tempTree;
|
79
|
-
|
80
|
-
N = atol(argv[1]);
|
81
|
-
|
82
|
-
minDepth = 4;
|
83
|
-
|
84
|
-
if ((minDepth + 2) > N)
|
85
|
-
maxDepth = minDepth + 2;
|
86
|
-
else
|
87
|
-
maxDepth = N;
|
88
|
-
|
89
|
-
stretchDepth = maxDepth + 1;
|
90
|
-
|
91
|
-
stretchTree = BottomUpTree(0, stretchDepth);
|
92
|
-
printf
|
93
|
-
(
|
94
|
-
"stretch tree of depth %u\t check: %li\n",
|
95
|
-
stretchDepth,
|
96
|
-
ItemCheck(stretchTree)
|
97
|
-
);
|
98
|
-
|
99
|
-
DeleteTree(stretchTree);
|
100
|
-
|
101
|
-
longLivedTree = BottomUpTree(0, maxDepth);
|
102
|
-
|
103
|
-
for (depth = minDepth; depth <= maxDepth; depth += 2)
|
104
|
-
{
|
105
|
-
long i, iterations, check;
|
106
|
-
|
107
|
-
iterations = 1 << (maxDepth - depth + minDepth);
|
108
|
-
|
109
|
-
check = 0;
|
110
|
-
|
111
|
-
for (i = 1; i <= iterations; i++)
|
112
|
-
{
|
113
|
-
tempTree = BottomUpTree(i, depth);
|
114
|
-
check += ItemCheck(tempTree);
|
115
|
-
DeleteTree(tempTree);
|
116
|
-
|
117
|
-
tempTree = BottomUpTree(-i, depth);
|
118
|
-
check += ItemCheck(tempTree);
|
119
|
-
DeleteTree(tempTree);
|
120
|
-
} /* for(i = 1...) */
|
121
|
-
|
122
|
-
printf
|
123
|
-
(
|
124
|
-
"%li\t trees of depth %u\t check: %li\n",
|
125
|
-
iterations * 2,
|
126
|
-
depth,
|
127
|
-
check
|
128
|
-
);
|
129
|
-
} /* for(depth = minDepth...) */
|
130
|
-
|
131
|
-
printf
|
132
|
-
(
|
133
|
-
"long lived tree of depth %u\t check: %li\n",
|
134
|
-
maxDepth,
|
135
|
-
ItemCheck(longLivedTree)
|
136
|
-
);
|
137
|
-
|
138
|
-
return 0;
|
139
|
-
} /* main() */
|
140
|
-
|
@@ -1,134 +0,0 @@
|
|
1
|
-
/* The Computer Language Benchmarks Game
|
2
|
-
http://shootout.alioth.debian.org/
|
3
|
-
|
4
|
-
contributed by Kevin Carson
|
5
|
-
modified by Anthony Piron
|
6
|
-
*/
|
7
|
-
|
8
|
-
#include <malloc.h>
|
9
|
-
#include <math.h>
|
10
|
-
#include <stdio.h>
|
11
|
-
#include <stdlib.h>
|
12
|
-
|
13
|
-
|
14
|
-
typedef struct tn {
|
15
|
-
struct tn* left;
|
16
|
-
struct tn* right;
|
17
|
-
long item;
|
18
|
-
} treeNode;
|
19
|
-
|
20
|
-
|
21
|
-
treeNode* InitTreeNode(treeNode* new, treeNode* left, treeNode* right, long item)
|
22
|
-
{
|
23
|
-
new->left = left;
|
24
|
-
new->right = right;
|
25
|
-
new->item = item;
|
26
|
-
|
27
|
-
return new;
|
28
|
-
} /* NewTreeNode() */
|
29
|
-
|
30
|
-
|
31
|
-
long ItemCheck(treeNode* tree)
|
32
|
-
{
|
33
|
-
if (tree->left == NULL)
|
34
|
-
return tree->item;
|
35
|
-
else
|
36
|
-
return tree->item + ItemCheck(tree->left) - ItemCheck(tree->right);
|
37
|
-
} /* ItemCheck() */
|
38
|
-
|
39
|
-
|
40
|
-
treeNode* BottomUpTreeBis(treeNode array[], long index,
|
41
|
-
long item, unsigned depth)
|
42
|
-
{
|
43
|
-
if (depth > 0)
|
44
|
-
return InitTreeNode
|
45
|
-
(
|
46
|
-
array + index,
|
47
|
-
BottomUpTreeBis(array, index*2+1, 2 * item - 1, depth - 1),
|
48
|
-
BottomUpTreeBis(array,index*2+2, 2 * item, depth - 1),
|
49
|
-
item
|
50
|
-
);
|
51
|
-
else
|
52
|
-
return InitTreeNode( array+index,NULL, NULL, item);
|
53
|
-
} /* BottomUpTree() */
|
54
|
-
|
55
|
-
treeNode* BottomUpTree(long item, unsigned depth)
|
56
|
-
{
|
57
|
-
treeNode* array = malloc(sizeof(treeNode)* pow(2,depth+1) );
|
58
|
-
|
59
|
-
return BottomUpTreeBis(array,0, item, depth);
|
60
|
-
}
|
61
|
-
|
62
|
-
void DeleteTree(treeNode* tree)
|
63
|
-
{
|
64
|
-
|
65
|
-
free(tree);
|
66
|
-
|
67
|
-
} /* DeleteTree() */
|
68
|
-
|
69
|
-
|
70
|
-
int main(int argc, char* argv[])
|
71
|
-
{
|
72
|
-
unsigned N, depth, minDepth, maxDepth, stretchDepth;
|
73
|
-
treeNode *stretchTree, *longLivedTree, *tempTree;
|
74
|
-
|
75
|
-
N = atol(argv[1]);
|
76
|
-
|
77
|
-
minDepth = 4;
|
78
|
-
|
79
|
-
if ((minDepth + 2) > N)
|
80
|
-
maxDepth = minDepth + 2;
|
81
|
-
else
|
82
|
-
maxDepth = N;
|
83
|
-
|
84
|
-
stretchDepth = maxDepth + 1;
|
85
|
-
|
86
|
-
stretchTree = BottomUpTree(0, stretchDepth);
|
87
|
-
printf
|
88
|
-
(
|
89
|
-
"stretch tree of depth %u\t check: %li\n",
|
90
|
-
stretchDepth,
|
91
|
-
ItemCheck(stretchTree)
|
92
|
-
);
|
93
|
-
|
94
|
-
DeleteTree(stretchTree);
|
95
|
-
|
96
|
-
longLivedTree = BottomUpTree(0, maxDepth);
|
97
|
-
|
98
|
-
for (depth = minDepth; depth <= maxDepth; depth += 2)
|
99
|
-
{
|
100
|
-
long i, iterations, check;
|
101
|
-
|
102
|
-
iterations = pow(2, maxDepth - depth + minDepth);
|
103
|
-
|
104
|
-
check = 0;
|
105
|
-
|
106
|
-
for (i = 1; i <= iterations; i++)
|
107
|
-
{
|
108
|
-
tempTree = BottomUpTree(i, depth);
|
109
|
-
check += ItemCheck(tempTree);
|
110
|
-
DeleteTree(tempTree);
|
111
|
-
|
112
|
-
tempTree = BottomUpTree(-i, depth);
|
113
|
-
check += ItemCheck(tempTree);
|
114
|
-
DeleteTree(tempTree);
|
115
|
-
} /* for(i = 1...) */
|
116
|
-
|
117
|
-
printf
|
118
|
-
(
|
119
|
-
"%li\t trees of depth %u\t check: %li\n",
|
120
|
-
iterations * 2,
|
121
|
-
depth,
|
122
|
-
check
|
123
|
-
);
|
124
|
-
} /* for(depth = minDepth...) */
|
125
|
-
|
126
|
-
printf
|
127
|
-
(
|
128
|
-
"long lived tree of depth %u\t check: %li\n",
|
129
|
-
maxDepth,
|
130
|
-
ItemCheck(longLivedTree)
|
131
|
-
);
|
132
|
-
|
133
|
-
return 0;
|
134
|
-
} /* main() */
|