Skip to content

Instantly share code, notes, and snippets.

@mattn
Last active October 3, 2017 17:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mattn/f5ae675d108ad05fbe224d0e4a42306a to your computer and use it in GitHub Desktop.
Save mattn/f5ae675d108ad05fbe224d0e4a42306a to your computer and use it in GitHub Desktop.
package main
import (
"strconv"
"syscall"
)
func main() {
n := 600000 * 3
for i := 1; i <= n; i++ {
if i%3 == 0 && i%5 == 0 {
syscall.Write(syscall.Stdout, []byte("FizzBuzz\n"))
} else if i%3 == 0 {
syscall.Write(syscall.Stdout, []byte("Fizz\n"))
} else if i%5 == 0 {
syscall.Write(syscall.Stdout, []byte("Buzz\n"))
} else {
syscall.Write(syscall.Stdout, []byte(strconv.Itoa(i)+"\n"))
}
}
}

C言語

Version Number:   Windows NT 6.2 (Build 9200)
Exit Time:        2:11 am, Wednesday, October 4 2017
Elapsed Time:     0:00:02.235
Process Time:     0:00:02.171
System Calls:     3658089    
Context Switches: 11695      
Page Faults:      1715       
Bytes Read:       90132      
Bytes Written:    13706254   
Bytes Other:      68184      

Go言語

Version Number:   Windows NT 6.2 (Build 9200)
Exit Time:        2:11 am, Wednesday, October 4 2017
Elapsed Time:     0:00:01.326
Process Time:     0:00:01.203
System Calls:     1817854    
Context Switches: 7157       
Page Faults:      3726       
Bytes Read:       5152949    
Bytes Written:    11799146   
Bytes Other:      52966      

Nim

Version Number:   Windows NT 6.2 (Build 9200)
Exit Time:        2:11 am, Wednesday, October 4 2017
Elapsed Time:     0:00:01.232
Process Time:     0:00:01.218
System Calls:     1818248    
Context Switches: 5948       
Page Faults:      1019       
Bytes Read:       439200     
Bytes Written:    13653866   
Bytes Other:      50114      

Go言語(mattn改良版)

Version Number:   Windows NT 6.2 (Build 9200)
Exit Time:        2:17 am, Wednesday, October 4 2017
Elapsed Time:     0:00:00.801
Process Time:     0:00:00.781
System Calls:     1809320    
Context Switches: 3779       
Page Faults:      2774       
Bytes Read:       38380      
Bytes Written:    11797586   
Bytes Other:      32516      
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment