Created
December 19, 2020 21:06
-
-
Save invisiblefunnel/e58195b9ef04ee224a82871e9994ed06 to your computer and use it in GitHub Desktop.
paulmach/osm cgo branch
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
package main | |
import ( | |
"fmt" | |
"io" | |
"log" | |
"os" | |
"github.com/cheggaaa/pb/v3" | |
"github.com/paulmach/osm/osmpbf" // cgo branch | |
) | |
func main() { | |
f, err := os.Open(os.Args[1]) | |
if err != nil { | |
log.Fatal(err) | |
} | |
defer checkClose(f) | |
info, err := f.Stat() | |
if err != nil { | |
panic(err) | |
} | |
bar := pb.Full.Start64(info.Size()) | |
reader := bar.NewProxyReader(f) | |
scanner := osmpbf.New(nil, reader, 1) | |
defer checkClose(scanner) | |
count := int64(0) | |
for scanner.Scan() { | |
count++ | |
} | |
fmt.Println("count", count) | |
} | |
func checkClose(c io.Closer) { | |
if err := c.Close(); err != nil { | |
panic(err) | |
} | |
} |
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
› time CGO_ENABLED=1 go run main.go planet-200803.osm.pbf | |
52.43 GiB / 52.43 GiB [---------------------------------->] 100.00% 19.46 MiB p/s ETA 0s | |
count 6913388422 | |
real 35m59.889s | |
user 58m7.569s | |
sys 1m14.607s | |
› time CGO_ENABLED=0 go run main.go planet-200803.osm.pbf | |
52.43 GiB / 52.43 GiB [---------------------------------->] 100.00% 16.01 MiB p/s ETA 0s | |
count 6913388422 | |
real 46m57.724s | |
user 69m3.568s | |
sys 1m12.096s |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
MacBook Pro (Retina, 15-inch, Mid 2015)
2.2 GHz Quad-Core Intel Core i7
16 GB 1600 MHz DDR3