package main
import("fmt"; "math")
func Sqrt(x float64) (z float64) {
z, delta := 1.0, 1.0
for delta > 1e-4 {
z0 := z
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[11:00] ~ $ ruby str_benchmark.rb | |
user system total real | |
interp 1.370000 2.020000 3.390000 ( 3.392649) | |
arrayjoin 0.030000 0.000000 0.030000 ( 0.029942) | |
concat 0.020000 0.000000 0.020000 ( 0.023137) | |
plusequals 1.560000 0.720000 2.280000 ( 2.269754) | |
user system total real | |
concat 0.020000 0.000000 0.020000 ( 0.020088) | |
interp 1.780000 2.090000 3.870000 ( 3.870043) | |
arrayjoin 0.020000 0.000000 0.020000 ( 0.021839) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'benchmark' | |
TIMES = 100_000 | |
strategies = [ | |
[ 'plusequals', proc { str = ""; TIMES.times { str += 'a' } } ], | |
[ 'interp', proc { str = ""; TIMES.times { str = "#{str}a" } } ], | |
[ 'concat', proc { str = ""; TIMES.times { str << "a" } } ], | |
[ 'arrayjoin', proc { ary = []; TIMES.times { ary << 'a' }; str = ary.join } ] ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
puts case true | |
when true == false | |
"nope" | |
when false == true | |
"also nope" | |
when [ :a ].empty? | |
"nope as well" | |
when nil.nil? | |
"yep!" | |
when false.nil? |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use std; | |
import io::reader_util; | |
enum node { | |
tag_node({ | |
name: str, | |
attributes: [attribute], | |
children: [node] | |
}), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
; Puts "random" numbers in X, Y, and Z | |
SET A, 0x1232 | |
JSR rand | |
SET X, A | |
JSR rand | |
SET Y, A | |
JSR rand | |
SET Z, A | |
SET PC, break |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
source 'https://rubygems.org' | |
gem 'resque', '1.20.0' | |
gem 'rake' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdlib.h> | |
#include <netinet/in.h> | |
#include <string.h> | |
#include <stdio.h> | |
#include <unistd.h> | |
#define MAX_CONNECTIONS 5 | |
#define BUFSIZE 1024 | |
typedef struct { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdlib.h> | |
#include <netinet/in.h> | |
#include <sys/un.h> | |
#include <string.h> | |
#include <stdio.h> | |
#include <unistd.h> | |
#define MAX_CONNECTIONS 5 | |
#define BUFSIZE 1024 | |
#define SOCKPATH "/tmp/migrate.sock" |
OlderNewer