Open Tough-Stone opened 4 years ago
没有。这个项目主要是用于模拟区块链的DAG结构,进而分析区块链的分叉、性能等,并不能用于具体的区块链系统。
明白,就是想问下怎么进行模拟
模拟用函数 simulate_blockchain,具体参数见帮助文档
这个BlockSim包找不到,是什么原因呢
这个包没有提交到CRAN,需要自己下载用源文件方式安装,或者用devtools包提供的工具:
library(devtools) install_github("wulingyun/BlockSim")
十分感谢。我执行simulate_blockchain以后,只是打印一些数据,统计图又是怎样生成的呢?
这个包没有提交到CRAN,需要自己下载用源文件方式安装,或者用devtools包提供的工具:
library(devtools) install_github("wulingyun/BlockSim")
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or unsubscribe.
R有很强大的统计和画图功能,需要根据具体目的去进行统计和画图
可以举个例子吗,根据计算出来的结果生成一张图片
R有很强大的统计和画图功能,需要根据具体目的去进行统计和画图
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or unsubscribe.
library(BlockSim) library(reshape2) library(ggplot2)
lambda <- seq(0, 0.1, length.out = 100)
y1 <- tx_per_second(sapply(lambda, estimate_growth_rate, block_size = 1), block_size = 1) y2 <- tx_per_second(sapply(lambda, estimate_growth_rate, block_size = 2), block_size = 2) y3 <- tx_per_second(sapply(lambda, estimate_growth_rate, block_size = 4), block_size = 4) y01 <- tx_per_second(lambda, block_size = 1) y02 <- tx_per_second(lambda, block_size = 2) y03 <- tx_per_second(lambda, block_size = 4)
TPS <- data.frame(lambda = lambda, y1 = y1, y2 = y2, y3 = y3) dd = melt(TPS, id=c("lambda"))
TPS0 <- data.frame(lambda = lambda, y1 = y01, y2 = y02, y3 = y03) dd0 = melt(TPS0, id=c("lambda")) dd0 <- dd0[dd0$value < 300, ]
p <- ggplot(dd) + geom_line(aes(x = lambda, y = value, colour = variable, linetype = "solid")) + geom_line(data = dd0, aes(x = lambda, y = value, colour = variable, linetype = "dashed")) + scale_colour_manual(name = "Block size", values = c("blue", "green", "red"), labels = c("1M", "2M", "4M")) + scale_linetype_manual(name = "Models", values = c("dashed", "solid"), labels = c("Theoretical maximum", "Gamma distribution")) + xlab("Block creation rate (block/s)") + ylab("Transaction Throughput (tx/s)") + theme(legend.position = c(0.01,0.99), legend.justification = c(0,1)) ggsave("TPS_lambda.png", p, height = 5, dpi = 1200)
十分感谢!
library(BlockSim) library(reshape2) library(ggplot2)
lambda <- seq(0, 0.1, length.out = 100)
y1 <- tx_per_second(sapply(lambda, estimate_growth_rate, block_size = 1), block_size = 1) y2 <- tx_per_second(sapply(lambda, estimate_growth_rate, block_size = 2), block_size = 2) y3 <- tx_per_second(sapply(lambda, estimate_growth_rate, block_size = 4), block_size = 4) y01 <- tx_per_second(lambda, block_size = 1) y02 <- tx_per_second(lambda, block_size = 2) y03 <- tx_per_second(lambda, block_size = 4)
TPS <- data.frame(lambda = lambda, y1 = y1, y2 = y2, y3 = y3) dd = melt(TPS, id=c("lambda"))
TPS0 <- data.frame(lambda = lambda, y1 = y01, y2 = y02, y3 = y03) dd0 = melt(TPS0, id=c("lambda")) dd0 <- dd0[dd0$value < 300, ]
p <- ggplot(dd) + geom_line(aes(x = lambda, y = value, colour = variable, linetype = "solid")) + geom_line(data = dd0, aes(x = lambda, y = value, colour = variable, linetype = "dashed")) + scale_colour_manual(name = "Block size", values = c("blue", "green", "red"), labels = c("1M", "2M", "4M")) + scale_linetype_manual(name = "Models", values = c("dashed", "solid"), labels = c("Theoretical maximum", "Gamma distribution")) + xlab("Block creation rate (block/s)") + ylab("Transaction Throughput (tx/s)") + theme(legend.position = c(0.01,0.99), legend.justification = c(0,1)) ggsave("TPS_lambda.png", p, height = 5, dpi = 1200)
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or unsubscribe.
请问有没有演示示例,如何使用这个项目