How long does the write operation of the database take
-
@tovax said in How long does the write operation of the database take:
QWriteLocker locker(&modelLock);
This looks fishy...
-
@tovax said in How long does the write operation of the database take:
QWriteLocker locker(&modelLock);
This looks fishy...
-
@Christian-Ehrlicher
Oh yes I didn't notice that! Could be making a huge difference!@tovax
Comment that out for a start and see whether it is making any difference? -
@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.
-
@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 :)
-
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 :)
-
@tovax
Don't forget:setData()
may be doing more than just writing a value to the database. For example, it raises adataChanged()
signal, and if you have a view slotted to that (and using the defaultDirectConnection
) you will be timing the whole of the view's response code here.... At minimum you might disable Qt signals for the duration. That's why I said profiling would be the best way to see what is really going on. -
@JonB I have checked the signals and slots of the database and there is no connection during the reading and writing test.
-
@JonB I have checked the signals and slots of the database and there is no connection during the reading and writing test.
@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?
-
@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.