performance test - write, fwrite and cll1 single arugment echo added
[svn/Cll1h/.git] / demos / performance / test-results2
CommitLineData
06ab91f0 1------------------------------------------------------------- Ruby
c3eef81f 2#!/usr/bin/ruby
3
410000000.times { print "stuff1"," ","stuff2","\n" }
283bc497 5
06ab91f0 6Running...
7real 0m24.569s
8user 0m23.113s
9sys 0m1.420s
10
11--------------------------------------------------- Python - range
b836e242 12#!/usr/bin/python
81088cec 13
14for i in range(1,10000000):
15 print "stuff1","stuff2"
16
06ab91f0 17Running...
18real 0m13.571s
19user 0m13.369s
20sys 0m0.200s
283bc497 21
06ab91f0 22-------------------------------------------------- Python - xrange
72c9d7a0 23#!/usr/bin/python
24
25for i in xrange(1,10000000):
26 print "stuff1","stuff2"
27
06ab91f0 28Running...
29real 0m13.118s
30user 0m13.105s
31sys 0m0.012s
283bc497 32
06ab91f0 33------------------------------------------------------------ PHP 5
ba41861f 34#!/usr/bin/php5 -q
35<?php
36for ( $i=0; $i<10000000; $i++ )
37{
38 echo "stuff1"." "."stuff2"."\n";
39}
40?>
06ab91f0 41Running..../test-performance2.sh: line 24: -f: command not found
67db9ef1 42
06ab91f0 43real 0m0.001s
44user 0m0.000s
45sys 0m0.000s
46
47-------------------------------------------------- C - gcc - write
67db9ef1 48#include <string.h>
49
50#define RUNS 10000000UL
51int main (void)
52{
53 unsigned long i;
54 char *s1="stuff1";
55 char *s2="stuff2";
56 int l1=strlen(s1);
57 int l2=strlen(s2);
58
59 for (i=0;i<RUNS;i++)
60 {
61 write(1,s1,l1);
62 write(1," ",1);
63 write(1,s2,l2);
64 write(1,"\n",1);
65 }
66 return 0;
67}
06ab91f0 68Compiling...
69real 0m0.063s
70user 0m0.044s
71sys 0m0.016s
72Running...
73real 0m11.514s
74user 0m3.572s
75sys 0m7.928s
76
77---------------------------------------------- C - g++ - std::cout
d8394559 78#include <iostream>
79
80#define RUNS 10000000UL
81int main()
82{
83 unsigned long i;
84 for (i=0;i<RUNS;i++) {
85 std::cout << "stuff1" << " " << "stuff2" << std::endl;
86 }
87 return 0;
88}
06ab91f0 89Compiling...
90real 0m0.367s
91user 0m0.336s
92sys 0m0.024s
93Running...
94real 0m8.012s
95user 0m6.092s
96sys 0m1.812s
97
98------------------------------------------------------------- Perl
81088cec 99#!/usr/bin/perl
100
101my $i=0;
102for ($i=0;$i<10000000;$i++)
103{
104 print ("stuff1"," ","stuff2","\n");
105}
06ab91f0 106Running..../test-performance2.sh: line 46: -f: command not found
107
108real 0m0.001s
109user 0m0.000s
110sys 0m0.004s
81088cec 111
06ab91f0 112------------------------------------------------- C - gcc - printf
81088cec 113#include <stdio.h>
114
115#define RUNS 10000000UL
116int main (void)
117{
118 unsigned long i;
06ab91f0 119 for (i=0;i<RUNS;i++)
120 {
81088cec 121 printf("%s %s\n","stuff2","stuff2");
122 }
123 return 0;
124}
06ab91f0 125Compiling...
126real 0m0.098s
127user 0m0.080s
128sys 0m0.016s
129Running...
130real 0m2.818s
131user 0m2.820s
132sys 0m0.000s
133
134------------------------------------------------- C - gcc - fwrite
135#include <stdio.h>
136#include <string.h>
283bc497 137
06ab91f0 138#define RUNS 10000000UL
139int main (void)
140{
141 unsigned long i;
142 char *s1="stuff1";
143 char *s2="stuff2";
144 int l1=strlen(s1);
145 int l2=strlen(s2);
146
147 for (i=0;i<RUNS;i++)
148 {
149 fwrite(s1,l1,1,stdout);
150 fwrite(" ",1,1,stdout);
151 fwrite(s2,l2,1,stdout);
152 fwrite("\n",1,1,stdout);
153 }
154 return 0;
155}
156Compiling...
157real 0m0.070s
158user 0m0.052s
159sys 0m0.016s
160Running...
161real 0m2.665s
162user 0m2.624s
163sys 0m0.012s
164
165----------------------------------------------- C<<1 - gcc - print
283bc497 166#include "cll1.h"
167
168program
169{
170 repeat(10000000)
171 print("stuff1","stuff2");
172}
06ab91f0 173Compiling...
174real 0m0.121s
175user 0m0.100s
176sys 0m0.016s
177Running...
178real 0m2.510s
179user 0m2.508s
180sys 0m0.004s
181
182-------------------------------------------------- C - gcc - fputs
81088cec 183#include <stdio.h>
184
185#define RUNS 10000000UL
186int main (void)
187{
188 unsigned long i;
189 for (i=0;i<RUNS;i++) {
190 fputs("stuff1",stdout);
191 fputs(" ",stdout);
192 fputs("stuff2",stdout);
193 fputs("\n",stdout);
194 }
195 return 0;
196}
06ab91f0 197Compiling...
198real 0m0.060s
199user 0m0.052s
200sys 0m0.008s
201Running...
202real 0m1.567s
203user 0m1.560s
204sys 0m0.008s
283bc497 205
This page took 0.310639 seconds and 4 git commands to generate.