Hi guys. Currently I'm working on metadata writing app based on Exiftool. I have some problems with performance and after some debugging I've spotted that this code takes a lot of time:
for (;;) {
cmdNum = mStdout.Read();
if (cmdNum) break;
if (getTime() >= doneTime) break;
if (mCmdQueue) Command(); // keep sending queued commands
usleep(1000); // chill and have a beer
}
Why here execution is blocked for 1000 micro seconds? I've deleted this line and I won ~3 seconds, but I think this line is important, isn't it?
Where did you find this piece of code? It's not part of exiftool (which Is 100% Perl, not C).
Looks like it's part of the C++ Interface (http://owl.phy.queensu.ca/~phil/cpp_exiftool/) in the ExifTool.cpp file.
Quote from: Hayo Baan on September 15, 2018, 04:31:08 AM
Where did you find this piece of code? It's not part of exiftool (which Is 100% Perl, not C).
This part of C++ Exiftool interface
usleep(1000) //line 718
usleep(100) //line 229
It was about time I had a look at the C++ interface, so thank you for your question :)
The sleep of one millisecond is (most likely) there only to prevent burdening the processor continuously with the loop execution. I'm surprised you actually notice this delay (unless you are using a very long list of commands), but it should be safe to make the delay smaller or even zero (though in the latter case one processor core will be used at 100% capacity during the loop run). The change should be made at line 718.
Cheers,
Hayo
Yes. That delay is there just to prevent the process from using 100% of the CPU when it is doing nothing.
- Phil
Thanks guys!