mirror of
https://github.com/tiennm99/zfoo.git
synced 2026-08-13 16:23:32 +00:00
perf[go]: 优化go的性能测试
This commit is contained in:
+6
-5
@@ -2,17 +2,18 @@ package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"testing"
|
||||
"time"
|
||||
)
|
||||
|
||||
func main() {
|
||||
func TestFibonacci(t *testing.T) {
|
||||
// 预热
|
||||
test()
|
||||
testFibonacci()
|
||||
// 正式执行
|
||||
test()
|
||||
testFibonacci()
|
||||
}
|
||||
|
||||
func test() {
|
||||
func testFibonacci() {
|
||||
var startTime = time.Now()
|
||||
for i := 0; i < 10000; i++ {
|
||||
fibonacci(32)
|
||||
@@ -51,4 +52,4 @@ public class MainTest {
|
||||
return fibonacci(i - 2) + fibonacci(i - 1);
|
||||
}
|
||||
}
|
||||
*/
|
||||
*/
|
||||
@@ -2,17 +2,18 @@ package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"testing"
|
||||
"time"
|
||||
)
|
||||
|
||||
func main() {
|
||||
func TestBubbleSort(t *testing.T) {
|
||||
// 预热
|
||||
test()
|
||||
testBubbleSort()
|
||||
// 正式执行
|
||||
test()
|
||||
testBubbleSort()
|
||||
}
|
||||
|
||||
func test() {
|
||||
func testBubbleSort() {
|
||||
var startTime = time.Now()
|
||||
const NUM int = 100000000
|
||||
for i := 0; i < NUM; i++ {
|
||||
Reference in New Issue
Block a user