Skip to content

Instantly share code, notes, and snippets.

@nitrix
Created December 16, 2019 05:25
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 nitrix/64e307cd448af069f80185df80c63182 to your computer and use it in GitHub Desktop.
Save nitrix/64e307cd448af069f80185df80c63182 to your computer and use it in GitHub Desktop.
Go image pkg overhead vs array
package main
import (
"fmt"
"image"
"image/color"
"time"
)
func main() {
// pixels := [1920 * 1080]uint8{}
img := image.NewRGBA(image.Rectangle{Max: image.Point{
X: 1920,
Y: 1080,
}})
before := time.Now()
for z := 0; z < 60; z++ {
for x := 0; x < 1920; x++ {
for y := 0; y < 1080; y++ {
// pixels[y * 1920 + x] = 1
img.Set(x, y, color.RGBA{
R: 255,
G: 255,
B: 255,
A: 255,
})
}
}
}
fmt.Println("Time: ", time.Since(before))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment