laziness, impatience, and hubris | |
PerlMonks |
Re: Just how efficent is using system() ?by grinder (Bishop) |
on Jul 02, 2003 at 20:50 UTC ( [id://270946]=note: print w/replies, xml ) | Need Help?? |
halley speaks the truth. Who cares? But your question is "how efficient is using system()". The answer is "not very". The kernel, at least in Unix land, has to allocate all sorts of structures to take the current process in order to fork it and take the child process and replace it with the process you want to run. This takes a non-trivial amount of time, at least as far as a CPU is concerned. In Win32 land the cost is similar; CreateProcess (or whatever it's called these days, I haven't touched the Windows API in 10 years) is not something you want to do in a tight inner loop. Anyway, you can consider that the upfront cost of performing a system call to be in the range of several hundred milliseconds. The second time you call it, the OS cache has been warmed and most of what you need is in RAM, so the subsequent cost drops by maybe an order of magnitude, so you're looking at possibly sub-100 millisecond start up time. What does this mean? Even if, in the worst case, the overall length of a single process run is one second, inserting "several thousand" records is going to take between one, two hours or a bit more. Do a run with the first ten records, ensure that it works, then fire up the rest and go out to lunch. While you're enjoying yourself, the computer is slowly grinding through the workload. Where's the wastage in that? Better than rendering a screen saver in any event. The other thing that springs to mind is that if you explain your problem in a bit more detail, some monk is going to pipe up and say "Oh, you just need to install Kerberos::MIT::Bulkloader and you can feed it a comma-delimited file and you're done." But without more information we just can't be sure. _____________________________________________
In Section
Seekers of Perl Wisdom
|
|