Re: Get Exact Time w/out Modules
by BrowserUk (Patriarch) on Nov 17, 2003 at 20:16 UTC
|
With your code running on proprietory hardware, there is no way for us to predict what facilities may be available to perform this task.
Most CPU's have very accurate hardware timers, and most OS's provide means to access them.
Whether such facilities are available on the embedded system in question is something only you can answer.
Examine what is said, not who speaks.
"Efficiency is intelligent laziness." -David Dunham
"Think for yourself!" - Abigail
Hooray!
Wanted!
| [reply] |
|
Well, the device runs embedded Linux on a PPC processor, if that helps.
| [reply] |
Re: Get Exact Time w/out Modules
by simonm (Vicar) on Nov 17, 2003 at 18:48 UTC
|
I can't use modules
Why not? What's the specific restriction you're dealing with? Site policy? Lack of install permissions? Lack of a compiler? Or... what?
If it's just a distribution problem, consider downloading Time::HiRes and copying bits of its source code into your program...
| [reply] |
|
The code is going to be running on an proprietary embedded device. To add software to the image that it runs requires me to pay a hefty sum of money. It has perl already, but no modules.
| [reply] |
|
If you can't compile libraries, I think you're limited to the time() function and its one second accuracy. (You might be able to qx() out to a command-line program that returned the time with hundredths of a second precision, but that'd probably take long enough that it would throw off your timing.
Update: Or, as mpeppler points out, you could use syscall(). It sounds like your manufacturer probably didn't include the headers or syscall.ph, but if they did this would be a good workaround.
| [reply] [d/l] [select] |
|
then you should consider getting rid of this proprietary device and going for something else. this kind of restrictiveness is like have a 10 ton block of cement chained to your ankle; you will never be able to get anywhere or do anything while you are still tied to it!
| [reply] |
|
Re: Get Exact Time w/out Modules
by ehdonhon (Curate) on Nov 17, 2003 at 20:31 UTC
|
So you have Perl, but no modules. I suspect that you will soon begin to conclude the Perl is a pain to program with. If you aren't going to be able to take advantage of the CPAN, then there seems to be very little sense in having Perl installed at all. It sounds to me like it would be much more to your advantage to program with a lower-level langauge, like C.
| [reply] |
|
So you have Perl, but no modules. I suspect that you will soon begin to conclude the Perl is a pain to program with
I'll have to disagree here - while CPAN is incredibly useful, you're still going to be much more productive coding in perl than in C even without access to it, and by using the syscall() built-in you can achieve pretty much anything that you need for low-level system functions. It's much more work than using various perl modules from CPAN, but it should get you there.
Michael
| [reply] |
|
For the most part perl covers our needs wonderfully...cases like this are the exception. We don't have a C compiler either (they make you buy an SDK for that), so perl is more or less our only choice.
| [reply] |
|
| [reply] |
Re: Get Exact Time w/out Modules
by Paul Smith (Initiate) on Nov 17, 2003 at 21:54 UTC
|
Well, if you're wanting to find out how long it takes for, say, performance profiling, you could try doing the 'something' lots of times - eg do it 1000 times, call time() before and after, and the difference in seconds for doing it 1000 times is going to be roughly the same as doing it once in milliseconds
| [reply] |
Re: Get Exact Time w/out Modules
by TomDLux (Vicar) on Nov 18, 2003 at 22:53 UTC
|
You have to pay to have 'standard software' installed, I guess because this imposes a cost on all aspects of the system.
Why not simply make Time::HiRes part of your application. If @INC does not include the current directory, begin your program with use lib '.';.
Update: If you can't compile it for the platform, that's a complication. But if you have the technology, pre-compile what you have to, and just make it all local.
--
TTTATCGGTCGTTATATAGATGTTTGCA
| [reply] |
|
| [reply] |