-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
42 lines (34 loc) · 822 Bytes
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
package main
import (
"fmt"
"time"
)
// Main Function
func main() {
PreDeclaredType()
NoDeclaredType()
}
// Pre declare the variables type
func PreDeclaredType() {
// Declare a start time for tracking speed
var startTime time.Time = time.Now()
// Declare the s variable 10^8 amount of times
for i := 0; i < 1000000000; i++ {
var s string = "this is a string!"
_ = s
}
// Print the speed
fmt.Printf("\nPreDeclaredType() -> %v\n", time.Since(startTime))
}
// No declared variable type
func NoDeclaredType() {
// Declare a start time for tracking speed
var startTime time.Time = time.Now()
// Declare the s variable 10^8 amount of times
for i := 0; i < 1000000000; i++ {
s := "this is a string!"
_ = s
}
// Print the speed
fmt.Printf("\nNoDeclaredType() -> %v\n\n", time.Since(startTime))
}