Git Product home page Git Product logo

Comments (3)

ivokwee avatar ivokwee commented on August 23, 2024

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.

ivokwee avatar ivokwee commented on August 23, 2024

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.

julianschmocker avatar julianschmocker commented on August 23, 2024

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 photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.