Solved How long does the write operation of the database take
-
@JonB
There is no difference after commenting out "QWriteLocker". -
@tovax said in How long does the write operation of the database take:
There is no difference after commenting out "QWriteLocker".
I don't see why you need it at all - that's why I pointed it out.
-
@Christian-Ehrlicher Hi, thank you very much, this class was a singleton class in the previous version, and the current version does not require a read-write lock.
-
So your previous implementation was wrong - you must not access the gui from without the main thread :)
-
@Christian-Ehrlicher Thank you very much for your reply :)
-
@JonB I have checked the signals and slots of the database and there is no connection during the reading and writing test.
-
@tovax To find out whether the write itself is slow you should omit the model and write directly using QSqlQuery.
-
@tovax
Well I'm not sure what you want us to say here? At your timings you can achieve ~15 write operations per second. I would not be very happy with this!Try:
timer.start(); for (int = 0; i < 10; i++) { model->setData(index, value, role); // change `index` and/or `value` } int64_t elapsedBuffer = timer.elapsed();
Does this take 10x as long??
I have checked the signals and slots of the database and there is no connection during the reading and writing test.
So you have no views at all attached to the model?
-
@JonB Hi, thank you very much for your patience.
- It takes 10x time.
- no views attached to the model.
- My purpose is to know how many milliseconds it takes for the database to read and write normally, ~ 80ms seems to be too long, I doubt my program.
- I created a demo program separately, and the reading and writing speed is very fast. I will reply to the final test results later.
-
@Christian-Ehrlicher @JonB @J-Hilk @jsulm
Thank you for your help. The reason for the slow speed should be the hard disk. The same demo takes about 80 ms for HDD and about 4 ms for SSD.