Last active
November 14, 2024 22:42
-
-
Save traversc/49f105fb3a05e8554d901fe0a6408e4c to your computer and use it in GitHub Desktop.
nanonext qs bench
This file contains hidden or 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
| library(ggplot2) | |
| library(dplyr) | |
| library(qs2) | |
| LEN <- 2^30 / 8 | |
| set.seed(314156); data <- rnorm(LEN) + seq(1,LEN,1) # 1 GB | |
| qs_send <- 4.40 # seconds | |
| serialize_send <- 1.94 | |
| qs_size <- length(qs_serialize(data, compress_level = 1, nthreads=4)) # 852 MB | |
| serialize_size <- length(serialize(data, connection = NULL)) # 1 GB | |
| # network speed in Mb/s | |
| network_speed <- seq(log(100), log(3000), length.out = 20) %>% exp | |
| df <- rbind( | |
| data.frame(network_speed = network_speed, time = qs_send + qs_size * 8 / (network_speed*2^20), method = "qs2"), | |
| data.frame(network_speed = network_speed, time = serialize_send + serialize_size * 8 / (network_speed*2^20), method = "serialize") | |
| ) | |
| ggplot(df, aes(x = network_speed, y = time, color = method)) + | |
| geom_line() + | |
| geom_point() + | |
| scale_x_log10() + | |
| scale_y_log10() + | |
| theme_bw() + | |
| labs(x = "Network speed (Mb/s)", y = "Time (s)") |
This file contains hidden or 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
| # send.R | |
| library(nanonext) | |
| library(qs2) | |
| mode <- 0L # serial or 0L | |
| s1 <- socket("pair", listen = "tcp://127.0.0.1:6556") # simulate network connection | |
| LEN <- 2^30 / 8 | |
| set.seed(314156); data <- rnorm(LEN) + seq(1,LEN,1) # 1 GB | |
| time <- Sys.time() | |
| msg <- send(s1, data, mode = mode, block = TRUE) | |
| print(Sys.time() - time) | |
| # recieve.R | |
| library(nanonext) | |
| library(qs2) | |
| mode <- 0L # serial or 0L | |
| s2 <- socket("pair", dial = "tcp://127.0.0.1:6556") | |
| msg <- recv(s2, mode = mode, block = TRUE) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment