Re: Calculate time difference in mini-second with VBScript




"Eric Wu" <wugh@xxxxxxxxxxxxxx> wrote in message
news:OLlsnH0QHHA.1200@xxxxxxxxxxxxxxxxxxxxxxx
Hi All,
I have two questions. First, we wrote a script to monitor file server
response time. But datediff() function can only calculate time difference
in
seconds. We are asked to provide data in mini-second. Is this possible in
VBScript? Or, i have to use vb.net?
2nd question, we wrote a script to list file service connection
information on a fie server, then try to check virus defination file on
connected client using WMI. But some of this client is not in our domain.
When this occurs, the script tale very long time to retry. Is is possible
to
set a timeout value before create a wmi connection?
Thank you very much for your time and any help.

Eric Wu

Hi,
I can't help with your second question.
On the timer question, plain VBScript does not have a way to access time
with less than 1 second resolution. The windows OS has timers with very
high resolution, but VBScript cannot directly get to them. There are free
COM objects that can access a higher resolution timer. One, called ASPTime,
is avalable here: http://www.cs.niu.edu/%7Ez951259/comlinks.html.

The Windows timer used by ASPTime has a variable resolution. On NT-type
systems ( for example, W2K & newer), it defaults to 10 milliseconds, but can
be as high as 1 millisecond, depending on the highest resolution currently
being used by any running application. So the trick is to guarantee its
being at 1 millisecond by running some little application, like running a
tiny HTML file with just this in the body:
<body>
<bgsound src="ding.wav" loop=0>
</body>
The 'ding' lasts under a second, but until you close this HTML file, the
sound software's request for 1 millisecond resolution remains in effect, so
ASPTime can get this resolution.

-Paul Randall


.



Relevant Pages

  • Re: [patch 00/21] hrtimer - High-resolution timer subsystem
    ... Right now the primary function of the state is to tell whether the timer ... > Of course if you consider the possibility of including high resolution ... problem requires solving problems in the clock abstraction first, ...
    (Linux-Kernel)
  • Re: [patch 00/21] hrtimer - High-resolution timer subsystem
    ... >> This way the list head is only necessary for the high resolution case. ... > (e.g. wakeup + timer restart). ... Even if the clock ...
    (Linux-Kernel)
  • Re: [PATCH] ktimers subsystem 2.6.14-rc2-kt5
    ... >>The cleanup I pointed out for the posix timer interval timers is pretty ... >>the posix timer structure. ... The rounding to the resolution value is explicitly required by the ... This says a) round to the next resolution, and b) don't allow the resulting timer to expire early. ...
    (Linux-Kernel)
  • Re: [PATCH] ktimers subsystem 2.6.14-rc2-kt5
    ... > a clock with a better resolution. ... > resolution than the physical clock has. ... reaches this count the timer is expired. ... OTOH We could also do this at the timer interrupt: ...
    (Linux-Kernel)
  • Re: VB6 code runs different speeds on different PCs
    ... As you've discovered, the minimum Sleep period can be different on different machines (5 milliseconds on my own WinXP system, but longer than that on others I think). ... You can get whatever "game rate" you want in a closed loop of course, by checking a high resolution timing source. ... If I were you I would use a proper Timer with a higher resolution that the standard VB Timer and run your entire game in the Timer event. ... Admittedly, updating their positions more than once every ten milliseconds does appear to give smoother animation (even though the video frame rate simply cannot draw a new frame at a rate greater than every 10 milliseconds,or so, depending on your display settings) because it tends iron out the differences more. ...
    (microsoft.public.vb.general.discussion)

Loading