add go results, just cause I'm learning it
This commit is contained in:
parent
fa63c6db6a
commit
707c180cab
25
test/bench/go/add.go
Normal file
25
test/bench/go/add.go
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
func fibo(n int ) int {
|
||||||
|
|
||||||
|
result := 0
|
||||||
|
a := 0
|
||||||
|
b := 1
|
||||||
|
i := 1
|
||||||
|
|
||||||
|
for( i < n ) {
|
||||||
|
result = a + b;
|
||||||
|
a = b;
|
||||||
|
b = result;
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
return result
|
||||||
|
}
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
sum := 1
|
||||||
|
for sum < 100000 {
|
||||||
|
sum += 1
|
||||||
|
fibo( 40 )
|
||||||
|
}
|
||||||
|
}
|
17
test/bench/go/calls.go
Normal file
17
test/bench/go/calls.go
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
func fib(n uint) uint {
|
||||||
|
if n < 2 {
|
||||||
|
return n
|
||||||
|
} else {
|
||||||
|
return fib(n-1) + fib(n-2)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
sum := 1
|
||||||
|
for sum < 1000 {
|
||||||
|
sum += 1
|
||||||
|
fib( 20 )
|
||||||
|
}
|
||||||
|
}
|
12
test/bench/go/hello.go
Normal file
12
test/bench/go/hello.go
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import "fmt"
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
sum := 1
|
||||||
|
for sum < 100000 {
|
||||||
|
sum += 1
|
||||||
|
fmt.Println("Hi there")
|
||||||
|
}
|
||||||
|
fmt.Println(sum)
|
||||||
|
}
|
13
test/bench/go/itos.go
Normal file
13
test/bench/go/itos.go
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"strconv"
|
||||||
|
)
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
sum := 1
|
||||||
|
for sum < 100000 {
|
||||||
|
sum += 1
|
||||||
|
strconv.Itoa(sum)
|
||||||
|
}
|
||||||
|
}
|
8
test/bench/go/loop.go
Normal file
8
test/bench/go/loop.go
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
sum := 1
|
||||||
|
for sum < 100000 {
|
||||||
|
sum += 1
|
||||||
|
}
|
||||||
|
}
|
@ -23,6 +23,7 @@ But results should be seen as relative, not absolute.
|
|||||||
|
|
||||||
language | loop | hello | itos | add | call
|
language | loop | hello | itos | add | call
|
||||||
c | 0,0500 | 2,1365 | 0,2902 | 0,1245 | 0,8535
|
c | 0,0500 | 2,1365 | 0,2902 | 0,1245 | 0,8535
|
||||||
|
go | 0.0485 | 4.5355 | 0.2143 | 0.0825 | 0.8769
|
||||||
soml | 0,0374 | 1,2071 | 0,7263 | 0,2247 | 1,3625
|
soml | 0,0374 | 1,2071 | 0,7263 | 0,2247 | 1,3625
|
||||||
|
|
||||||
ruby | 0,3 | 8.882 | 0,8971 | 3,8452
|
ruby | 0,3 | 8.882 | 0,8971 | 3,8452
|
||||||
|
Loading…
x
Reference in New Issue
Block a user