Comments (3)
I have done some tests. RDS is slowest because you need to read the whole rds object and write on each adding of a new message. This can become slow if you have thousands of messages. DBI is much faster as you do not need to write the entire table upon each message.
I also implemented a CSV connector. It uses data.table::fread and fwrite. They are fast. But also each message is just appended to the file, so not the whole table needs to be written. Furthermore, we if we do not need the whole chat history, can read only the last say 100 lines, so not the entire table needs to be read. I think also for the DBI connector it would be good to just retrieve the last 100 chat posts.
from shinychatr.
Code to benchmark. DBI is fastest, CSV is good, RDS is slow.
c1 <- shinyChatR:::RDSConnection$new("chat-data.rds")
c2 <- shinyChatR:::CSVConnection$new("chat-data.csv",nlast=100)
c3 <- shinyChatR:::DBConnection$new(db_file="chat-data.db")
msg = lorem::ipsum(1)[[1]]
system.time(
for(i in 1:4000) {
c1$insert_message(msg, user="alice", time="00:00:00")
d1 <- c1$get_data()
}
)
system.time(
for(i in 1:4000) {
c2$insert_message(msg, user="alice", time="00:00:00")
d1 <- c2$get_data()
}
)
system.time(
for(i in 1:4000) {
c3$insert_message(msg, user="alice", time="00:00:00")
d1 <- c3$get_data()
}
)
from shinychatr.
This is good to know. I guess that for large amounts of data the DBI with a SQLite connection is not optimal. In these case sever based database like PostgreSQL is preferred.
from shinychatr.
Related Issues (4)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from shinychatr.