| 1 | AMD Athlon(tm) XP 1259.392 Mhz 2520.58 bogomips |
| 2 | ------------------------------------------------------------- Ruby |
| 3 | #!/usr/bin/ruby |
| 4 | |
| 5 | 10000000.times { print "stuff1"," ","stuff2","\n" } |
| 6 | |
| 7 | Running... |
| 8 | real 0m50.940s |
| 9 | user 0m49.107s |
| 10 | sys 0m1.836s |
| 11 | |
| 12 | --------------------------------------------------- Python - range |
| 13 | #!/usr/bin/python |
| 14 | |
| 15 | for i in range(1,10000000): |
| 16 | print "stuff1","stuff2" |
| 17 | |
| 18 | Running... |
| 19 | real 0m25.547s |
| 20 | user 0m25.230s |
| 21 | sys 0m0.320s |
| 22 | |
| 23 | -------------------------------------------------- Python - xrange |
| 24 | #!/usr/bin/python |
| 25 | |
| 26 | for i in xrange(1,10000000): |
| 27 | print "stuff1","stuff2" |
| 28 | |
| 29 | Running... |
| 30 | real 0m26.269s |
| 31 | user 0m26.254s |
| 32 | sys 0m0.016s |
| 33 | |
| 34 | ------------------------------------------------------------ PHP 5 |
| 35 | #!/usr/bin/php5 -q |
| 36 | <?php |
| 37 | for ( $i=0; $i<10000000; $i++ ) |
| 38 | { |
| 39 | echo "stuff1"." "."stuff2"."\n"; |
| 40 | } |
| 41 | ?> |
| 42 | Running... |
| 43 | real 0m18.649s |
| 44 | user 0m14.449s |
| 45 | sys 0m4.200s |
| 46 | |
| 47 | -------------------------------------------------- C - gcc - write |
| 48 | #include <string.h> |
| 49 | |
| 50 | #define RUNS 10000000UL |
| 51 | int 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 | } |
| 68 | Compiling... |
| 69 | real 0m0.188s |
| 70 | user 0m0.164s |
| 71 | sys 0m0.024s |
| 72 | Running... |
| 73 | real 0m21.353s |
| 74 | user 0m7.572s |
| 75 | sys 0m13.781s |
| 76 | |
| 77 | ---------------------------------------------- C - g++ - std::cout |
| 78 | #include <iostream> |
| 79 | |
| 80 | #define RUNS 10000000UL |
| 81 | int 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 | } |
| 89 | Compiling... |
| 90 | real 0m0.986s |
| 91 | user 0m0.904s |
| 92 | sys 0m0.080s |
| 93 | Running... |
| 94 | real 0m14.836s |
| 95 | user 0m10.425s |
| 96 | sys 0m4.416s |
| 97 | |
| 98 | ------------------------------------------------------------- Perl |
| 99 | #!/usr/bin/perl |
| 100 | |
| 101 | my $i=0; |
| 102 | for ($i=0;$i<10000000;$i++) |
| 103 | { |
| 104 | print ("stuff1"," ","stuff2","\n"); |
| 105 | } |
| 106 | Running... |
| 107 | real 0m14.115s |
| 108 | user 0m13.005s |
| 109 | sys 0m0.012s |
| 110 | |
| 111 | ------------------------------------------------- C - tcc - printf |
| 112 | #include <stdio.h> |
| 113 | |
| 114 | #define RUNS 10000000UL |
| 115 | int main (void) |
| 116 | { |
| 117 | unsigned long i; |
| 118 | for (i=0;i<RUNS;i++) |
| 119 | { |
| 120 | printf("%s %s\n","stuff2","stuff2"); |
| 121 | } |
| 122 | return 0; |
| 123 | } |
| 124 | Compiling... |
| 125 | real 0m0.012s |
| 126 | user 0m0.008s |
| 127 | sys 0m0.004s |
| 128 | Running... |
| 129 | real 0m4.987s |
| 130 | user 0m4.856s |
| 131 | sys 0m0.032s |
| 132 | |
| 133 | ------------------------------------------------- C - tcc - fwrite |
| 134 | #include <stdio.h> |
| 135 | #include <string.h> |
| 136 | |
| 137 | #define RUNS 10000000UL |
| 138 | int main (void) |
| 139 | { |
| 140 | unsigned long i; |
| 141 | char *s1="stuff1"; |
| 142 | char *s2="stuff2"; |
| 143 | int l1=strlen(s1); |
| 144 | int l2=strlen(s2); |
| 145 | |
| 146 | for (i=0;i<RUNS;i++) |
| 147 | { |
| 148 | fwrite(s1,l1,1,stdout); |
| 149 | fwrite(" ",1,1,stdout); |
| 150 | fwrite(s2,l2,1,stdout); |
| 151 | fwrite("\n",1,1,stdout); |
| 152 | } |
| 153 | return 0; |
| 154 | } |
| 155 | Compiling... |
| 156 | real 0m0.017s |
| 157 | user 0m0.012s |
| 158 | sys 0m0.004s |
| 159 | Running... |
| 160 | real 0m3.678s |
| 161 | user 0m3.672s |
| 162 | sys 0m0.004s |
| 163 | |
| 164 | ----------------------------------------------- C<<1 - tcc - print |
| 165 | #include "cll1.h" |
| 166 | |
| 167 | program |
| 168 | { |
| 169 | repeat(10000000) |
| 170 | print("stuff1","stuff2"); |
| 171 | } |
| 172 | Compiling... |
| 173 | real 0m0.022s |
| 174 | user 0m0.016s |
| 175 | sys 0m0.004s |
| 176 | Running... |
| 177 | real 0m4.853s |
| 178 | user 0m4.836s |
| 179 | sys 0m0.016s |
| 180 | |
| 181 | -------------------------------------------------- C - tcc - fputs |
| 182 | #include <stdio.h> |
| 183 | |
| 184 | #define RUNS 10000000UL |
| 185 | int main (void) |
| 186 | { |
| 187 | unsigned long i; |
| 188 | for (i=0;i<RUNS;i++) { |
| 189 | fputs("stuff1",stdout); |
| 190 | fputs(" ",stdout); |
| 191 | fputs("stuff2",stdout); |
| 192 | fputs("\n",stdout); |
| 193 | } |
| 194 | return 0; |
| 195 | } |
| 196 | Compiling... |
| 197 | real 0m0.012s |
| 198 | user 0m0.008s |
| 199 | sys 0m0.004s |
| 200 | Running... |
| 201 | real 0m4.065s |
| 202 | user 0m4.040s |
| 203 | sys 0m0.024s |
| 204 | |
| 205 | ------------------------------------------------- C - gcc - printf |
| 206 | #include <stdio.h> |
| 207 | |
| 208 | #define RUNS 10000000UL |
| 209 | int main (void) |
| 210 | { |
| 211 | unsigned long i; |
| 212 | for (i=0;i<RUNS;i++) |
| 213 | { |
| 214 | printf("%s %s\n","stuff2","stuff2"); |
| 215 | } |
| 216 | return 0; |
| 217 | } |
| 218 | Compiling... |
| 219 | real 0m0.180s |
| 220 | user 0m0.152s |
| 221 | sys 0m0.028s |
| 222 | Running... |
| 223 | real 0m4.877s |
| 224 | user 0m4.860s |
| 225 | sys 0m0.020s |
| 226 | |
| 227 | ------------------------------------------------- C - gcc - fwrite |
| 228 | #include <stdio.h> |
| 229 | #include <string.h> |
| 230 | |
| 231 | #define RUNS 10000000UL |
| 232 | int main (void) |
| 233 | { |
| 234 | unsigned long i; |
| 235 | char *s1="stuff1"; |
| 236 | char *s2="stuff2"; |
| 237 | int l1=strlen(s1); |
| 238 | int l2=strlen(s2); |
| 239 | |
| 240 | for (i=0;i<RUNS;i++) |
| 241 | { |
| 242 | fwrite(s1,l1,1,stdout); |
| 243 | fwrite(" ",1,1,stdout); |
| 244 | fwrite(s2,l2,1,stdout); |
| 245 | fwrite("\n",1,1,stdout); |
| 246 | } |
| 247 | return 0; |
| 248 | } |
| 249 | Compiling... |
| 250 | real 0m0.205s |
| 251 | user 0m0.156s |
| 252 | sys 0m0.048s |
| 253 | Running... |
| 254 | real 0m3.640s |
| 255 | user 0m3.620s |
| 256 | sys 0m0.020s |
| 257 | |
| 258 | ----------------------------------------------- C<<1 - gcc - print |
| 259 | #include "cll1.h" |
| 260 | |
| 261 | program |
| 262 | { |
| 263 | repeat(10000000) |
| 264 | print("stuff1","stuff2"); |
| 265 | } |
| 266 | Compiling... |
| 267 | real 0m0.378s |
| 268 | user 0m0.336s |
| 269 | sys 0m0.040s |
| 270 | Running... |
| 271 | real 0m4.457s |
| 272 | user 0m4.448s |
| 273 | sys 0m0.012s |
| 274 | |
| 275 | -------------------------------------------------- C - gcc - fputs |
| 276 | #include <stdio.h> |
| 277 | |
| 278 | #define RUNS 10000000UL |
| 279 | int main (void) |
| 280 | { |
| 281 | unsigned long i; |
| 282 | for (i=0;i<RUNS;i++) { |
| 283 | fputs("stuff1",stdout); |
| 284 | fputs(" ",stdout); |
| 285 | fputs("stuff2",stdout); |
| 286 | fputs("\n",stdout); |
| 287 | } |
| 288 | return 0; |
| 289 | } |
| 290 | Compiling... |
| 291 | real 0m0.190s |
| 292 | user 0m0.172s |
| 293 | sys 0m0.020s |
| 294 | Running... |
| 295 | real 0m2.556s |
| 296 | user 0m2.544s |
| 297 | sys 0m0.012s |