In [1]:
library(sf)
## rocker_geospatial_sf/demo/bm_wkb.R
##  vbox   Xeon(R) CPU E5-2640 v3
Linking to GEOS 3.6.2, GDAL 2.2.3, proj.4 4.9.3
In [2]:
# benchmark, comparing reading of largish simple feature objects from WKB
WKB_LINESTRING = function(m = 1, n) {
	stopifnot(m > 0 && n > 1)
	l = lapply(seq_len(m), function(x) {
		con = rawConnection(raw(0), "w")
		writeBin(as.raw(1), con) # "little"
		writeBin(2L, con, 4)     # "XY", "LINESTRING"
		writeBin(as.integer(n), con, 4) # npts
		writeBin(as.double(1:(2*n)), con)
		r = rawConnectionValue(con)
		close(con)
		r
	})
	structure(l, class = "WKB")
}
WKB_MULTILINESTRING = function(m = 1, n = 2, p = 2) {
	con = rawConnection(raw(0), "w")
	writeBin(as.raw(1), con) # "little"
	writeBin(5L, con, 4)     # "XY", "MULTILINESTRING"
	writeBin(as.integer(n), con, 4) # nlines
	r = rawConnectionValue(con)
	close(con)
	structure(list(do.call(c, append(r, WKB_LINESTRING(n, p)))), class = "WKB")
}

mls = WKB_MULTILINESTRING(1, 5e5)
ls1 = WKB_LINESTRING(1, 1e6)
ls2 = WKB_LINESTRING(5e5, 2) 

system.time(sf::st_as_sfc(mls, pureR = TRUE))
system.time(sf::st_as_sfc(mls))
system.time( wkb::readWKB(mls))

system.time(sf::st_as_sfc(ls1, pureR = TRUE))
system.time(sf::st_as_sfc(ls1))
system.time( wkb::readWKB(ls1))

system.time(sf::st_as_sfc(ls2, pureR = TRUE))
system.time(sf::st_as_sfc(ls2))
system.time( wkb::readWKB(ls2))
   user  system elapsed 
 43.852   0.132  43.997 
   user  system elapsed 
  0.617   0.005   0.622 
   user  system elapsed 
130.990   0.137 131.147 
   user  system elapsed 
  0.033   0.070   0.102 
   user  system elapsed 
   0.05    0.00    0.05 
   user  system elapsed 
  9.657   0.002   9.667 
   user  system elapsed 
 88.189   0.191  88.402 
   user  system elapsed 
  2.968   0.006   2.973 
   user  system elapsed 
344.493   0.622 345.163