Unsolved QFile save for usb drive
-
I have no problem when I copy file from usb to internal hard disk or internal hard disk to usb stick. Compare to the speed for copying file by windows explorer, copying file by QFile::copy() is not slow. It is slow when I save file to usb stick by QFile/QDataStream. Also when I browse directories, qdir.entryList() shows poor performance compare to explorer or other windows programs. For example if I enter a directory with 10000 files, it takes more than one minute to finish qdir.entryList().
-
@samdol
ok. so we assume device is ok.
Did you try test program and compared elapse times?
0.3 is not slow as such.
Could be interesting to see where you land.What is myData ?
One big array ?update:
triedFor /L %i in (1,1,10000) do fsutil file createnew B%i.tmp 65536
gives me 10.000 files on usb stick.
(unmount / mount before test to avoid cashing)#include <QDir> void MainWindow::on_pushButton_2_released() { auto start = std::chrono::high_resolution_clock::now(); QDir qdir("g:/"); QStringList fn_list = qdir.entryList( QDir::NoDotAndDotDot | QDir::NoSymLinks | QDir::Hidden | QDir::Files); auto finish = std::chrono::high_resolution_clock::now(); std::chrono::duration<double> elapsed = finish - start; qDebug() << "Elapsed time: " << elapsed.count(); }
Elapsed time: 1.54938
So under 2 secs.
This is win 10. Qt 5.7. -
@mrjj
Thank you for your example.
When I run on_pushButton_released() first time, I got
Elapsed time: 16.3639
but when I run it second time and later
Elapsed time: 0.280801
When I run on_pushButton_2_released() for directory with 10000 files on usb, the result is
Elapsed time: 53.6064
quite slow compare to your result. I used windows7 and Qt 5.6.2
Does it mean qdir.entryList() does not like my usb drive
or should I upgrade to Qt 5.7? -
Hi
Could you try with clean / new usb stick ?Those numbers are pretty high for entryList.
Are those files in sub folders?
Its hard to say if it is device or driver issue or something with windows.
or if it simply is that slow in some cases.If time permits simple install 5.7 along side 5.6 and test if it changes anything.
I will also test on a win 7 tomorrow just to be sure.
-
@mrjj
As you suggested, it seems that could be a problem of Qt 5.6.2.
After long wait, finally I could try to compile Qt 5.7.1 in my machine today.
I have downloaded qt-everywhere 5.7.1 and tried to compile in windows 7 platform.
I did
configure -prefix C:\Qt\5.7.1 -static -release -platform win32-g++ -no-compile-examples -opengl desktop
and then
mingw32-make
After several hours(Slow machine), I met the following error message
In file included from release\statemachine.cpp:7:0:
release\statemachine.h:10:30: fatal error: QScxmlStateMachine: No such file or directory
#include <QScxmlStateMachine>
^
compilation terminated.
Makefile.Release:135: recipe for target '.obj/release/statemachine.o' failed.Do I have to add some extra options to configure to solve this problem?
-
Hi,
Since you are upgrading, why not 5.9.1 ?
-
@SGaist
Because my license is expired and I could not download that version with my account. I used Mingw 4.9.1 to compile it. Do I have to use 5.3 version to compile Qt 5.7.1? -
@samdol Do you have a commercial Qt license?
-
@jsulm
It is paid for developement with Qt. before it is expired, I could download Qt 5.9 alpha version. I am not sure whether I could use this as commercial version because when I download alpha version, my license was still valid. -
Hi
Can't you just grap it directly then ?
https://download.qt.io/official_releases/qt/5.9/5.9.1/Or something Im missing?
-
@mrjj
I could download enterprise version before 5.9 but since my license expired, I could not gain it. By the way, I could compile Qt 5.6.2 with that configure options but Qt 5.7.1 always spews error when I tried to compile with the same options. I could not understand the method to compile for Qt 5.6.2 did not apply to Qt 5.7.1. -
@samdol Is there a reason why you compile Qt by yourself?
-
@jsulm
I need to develop a stand alone application which requires static build of Qt. I could do with Qt 5.6.2 but I could not do it anymore for 5.7.1. I don't know whether there is big change between them. -
@samdol Why don't you build Qt 5.9.1? This is the latest version. If you say you have errors while compiling you should say which errors and which compiler you're using.
-
@jsulm
I could not use Qt 5.9.1 as a commercial version because my license has expired.
I downloaded Qt 5.7.1 and configured by
configure -prefix C:\Qt\5.7.1 -static -release -platform win32-g++ -no-compile-examples -opengl desktop
and then
mingw32-make
After several hours(Slow machine), I met the following error message
In file included from release\statemachine.cpp:7:0:
release\statemachine.h:10:30: fatal error: QScxmlStateMachine: No such file or directory
#include <QScxmlStateMachine>
^
compilation terminated.
Makefile.Release:135: recipe for target '.obj/release/statemachine.o' failed.This is quite strange, because when I compile Qt 5.6.2 with the same options, It could compile well. I used mingw4.9.3 and mingw7.1 but the results are the same.
-
If you have a slot machine then you should avoid building modules you don't use. That will be a gain of time and space. You can always build additional modules on demand.
-
Following the instruction by
http://dimitris.apeiro.gr/2015/06/24/build-a-static-qt5-for-windows-by-compiling/
I could compile Qt 5.7.1. It seems some of configure options were not correct. I'll check it out more closely.
So I prepared a Qt 5.7.1 in windows 10 and when I run on_pushButton_2_released() by mrjj, it still shows poor performance. It takes 24 seconds for 10000 files on usb 2.0 drive. Now I am getting confused. Before I thought because Qt 5.6.2 is slow for entryList of files in usb. But changing Qt 5.7.1 did not improve much. If it is the problem of usb stick, accessing file should be slow with other programs. But other programs could access files on this usb very quickly. -
@samdol
Hi
Can you possible try the USB stick + program on other computer?
Win 10 if possible.You are right to think there is something fishy. If it was the device, explorer should be slow too.
So i do wonder.
-
When I run on_pushButton_2_released() to access the directory with 10000 files on hard disk it took less than a second. But accessing the same directory on usb 2.0 stick takes 53 seconds. I also tried QDirIterator but the results are the same. So I run the code in another machine with windows 10 to the same usb stick, no difference. Did it take less than a second when you access the directory with 10000 files on usb 2.0 stick?
-
@samdol
Hi
I tried Qt5.7 static and its maximum 1.2 sec on the oldest usb stick i could find.
win 10
But inside virtual win 7.
Pretty slow. Explorer show it instantly.I wish i had an other win 7 to try on.