[#4766] Wiki — "Glen Stampoultzis" <trinexus@...>

21 messages 2000/09/04
[#4768] RE: Wiki — "NAKAMURA, Hiroshi" <nahi@...> 2000/09/04

Hi, Glen,

[#4783] Re: Wiki — Masatoshi SEKI <m_seki@...> 2000/09/04

[#4785] Re: Wiki — "NAKAMURA, Hiroshi" <nakahiro@...> 2000/09/05

Howdy,

[#4883] Re-binding a block — Dave Thomas <Dave@...>

16 messages 2000/09/12

[#4930] Perl 6 rumblings -- RFC 225 (v1) Data: Superpositions — Conrad Schneiker <schneik@...>

Hi,

11 messages 2000/09/15

[#4936] Ruby Book Eng. translation editor's questions — Jon Babcock <jon@...>

20 messages 2000/09/16

[#5045] Proposal: Add constants to Math — Robert Feldt <feldt@...>

15 messages 2000/09/21

[#5077] Crazy idea? infix method calls — hal9000@...

This is a generalization of the "in" operator idea which I

17 messages 2000/09/22

[#5157] Compile Problem with 1.6.1 — Scott Billings <aerogems@...>

When I try to compile Ruby 1.6.1, I get the following error:

15 messages 2000/09/27

[ruby-talk:4781] Bug in Time.times on NT?

From: Robert Feldt <feldt@...>
Date: 2000-09-04 14:13:30 UTC
List: ruby-talk #4781
Hi,

There seems to be a bug in the script below when I run it on my machine.
(If this has been fixed in 1.6 then please discard this mail).

The problem might be with the 'time_s_times' func in time.c:

    hProc = GetCurrentProcess();
    GetProcessTimes(hProc,&create, &exit, &kernel, &user);
    return rb_struct_new(S_Tms,
rb_float_new((double)(kernel.dwHighDateTime*2e32+kernel.dwLowDateTime)/2e6
),
rb_float_new((double)(user.dwHighDateTime*2e32+user.dwLowDateTime)/2e6),
      rb_float_new((double)0),
      rb_float_new((double)0));

where I think the conversion should be something like

rb_float_new((user.dwHighDateTime * CONST_2_to_32 + user.dwLowDateTime) /
1e7)

etc...

where CONST_2_to_32 is 2**32 ie. 4294967296.0

If I've correctly unerstood the FILETIME structure returned from
Win32 API GetProcessTimes (with two 32-bit values giving the number of 100
nanosec intervals).

Regards,

Robert

The script:

#!/usr/local/bin/ruby
#
# When run on my IBM Thinkpad with Nt4, cygwin 1.1 & Ruby 1.4.5 this
script
# results in:
#
# bash-2.04$ time ruby ruby_times_test.rb
# Time: real = 9.5 s, user = 157.5 s, system = 0.2 s
#
# real    0m9.584s
# user    0m9.483s
# sys     0m0.060s
#
# How come user CPU time is reported to be 157.5 secs even though total 
# time was only about 10 secs? Bug? Fixed in 1.6?
#
s = 0
t_start = Time.now
pt_start = Time.times
1e6.to_i.times{ |i| s+= i }
pt_end = Time.times
t_end = Time.now
print "Time: real = %.1f s, user = %.1f s, system = %.1f s\n" % [t_end -
t_start, pt_end.utime - pt_start.utime, pt_end.stime - pt_start.stime]



In This Thread