Created
February 26, 2019 18:38
-
-
Save hslr4/472eaf93cc7553b5328943782ad560ae to your computer and use it in GitHub Desktop.
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
func appendInBasicLoop(kind string) training.Examples { | |
samp := getSamples(1000) | |
data := make([]training.Example, 0, len(samp)) | |
times := 1000 | |
results := make([]time.Duration, 0, times) | |
for trys := 0; trys < times; trys++ { | |
start := time.Now() | |
for j, s := range samp { | |
var test []int | |
switch kind { | |
case "zero": | |
test = make([]int, 0) | |
case "calc": | |
test = make([]int, 0, s*3+j) | |
case "func": | |
test = make([]int, 0, getCap(s, j)) | |
case "model": | |
test = make([]int, 0, getCapFromModel(s, j)) | |
case "model+1": | |
test = make([]int, 0, getCapFromModel(s, j)+1) | |
} | |
for i := 0; i < s; i++ { | |
test = append(test, i) | |
test = append(test, j) | |
test = append(test, s) | |
} | |
for k := 0; k < j; k++ { | |
test = append(test, k) | |
} | |
data = append(data, | |
training.Example{ | |
Input: []float64{float64(s), float64(j)}, | |
Response: []float64{float64(len(test))}}) | |
} | |
elapsed := time.Now().Sub(start) | |
results = append(results, elapsed) | |
} | |
printSummary(results) | |
return data | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment