What’s the fastest way?

Asked

Viewed 70 times

-1

I made a little game in Java and the players' dice are in the database, when a player enters, he is placed in a ArrayList<PlayerData> where it contains the getters and setters of level, money and etc.

When the player leaves the game, the dice are saved in the database and every 60 seconds all player data within the game is also saved.

I modify the level, money in ArrayList<PlayerData> instead of modifying directly in the database (within Java).

The "game" would go faster if instead of me changing by ArrayList<PlayerData> and then save in the database, I modify directly in the database? Or would it be the same thing? Would there be some way to improve this?

  • Did any of the answers solve your question? Do you think you can accept one of them? Check out the [tour] how to do this, if you haven’t already. You would help the community by identifying what was the best solution for you. You can accept only one of them. But you can vote on any question or answer you find useful on the entire site (when you have enough score).

2 answers

2


Hard to sink without knowing more information, but it is highly likely that keep in memory will always be faster under normal conditions. Access to an external device has always been much slower, even if it is an SSD. This may change with non-volatile memories, but we still don’t know how.

But if you are worried about performance you can review other things in the application, maybe eliminating getters and setters, that in many scenarios are unnecessary and cause slowness. Probably there are other things in the code that are making it slow and not even know.

-1

I believe that it is much more feasible to modify directly in the bank and only recover the information, than you use the code to then save, of course if you want to do both can use a Thread, surely it would improve the performance of the app, because I wouldn’t need to do it one at a time, but the two independent of each other.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.