Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
RE: [stellation-res] Could someone please run this program in Windows?

> >-----Original Message-----
> >From: stellation-res-admin@xxxxxxxxxxxxxxx
> >[mailto:stellation-res-admin@xxxxxxxxxxxxxxx]On Behalf Of Dave Shields
> >Sent: September 12, 2002 4:43 PM
> >To: stellation-res@xxxxxxxxxxxxxxx
> >Subject: [stellation-res] Could someone please run this program in
> >Windows?
> >
> >
> >Could someone please run this program in Windows and report the results:
> >cat <Time.java
> >import java.io.File;
> >import java.io.FileWriter;
> >import java.io.IOException;
> >import java.util.Date;
> >
> >public class Time{
> >    public static long now() {
> >        return new Long(new Date().getTime()).longValue();
> >    }
> >    public static long seconds(long time) {
> >        return time - ( time % 1000L);
> >    }
> >
> >    public static long elapsed(long now, long start) {
> >        return now - start;
> >    }
> >
> >    public static void main(String [] args) throws IOException {
> >
> >        long start = seconds(now()); // Start time
> >        File file = new File("foo");
> >        for (int i = 0; i < 25; i++) {
> >            if (file.exists()) file.delete();
> >            FileWriter fileWriter = new FileWriter(file);
> >            fileWriter.write(new char[] {'b', 'a', 'r', '\n' });
> >            fileWriter.flush();
> >            fileWriter.close();
> >            long fileTime = file.lastModified();
> >            long now = now();
> >            System.out.println(" time "
> >                               + elapsed(now, start)
> >                               + ", file "
> >                               + elapsed(fileTime, start));
> >            Object object = new Integer("0");
> >            try {
> >                synchronized (object) {
> >                    object.wait(100L);
> >                }
> >            }
> >            catch (InterruptedException e) {
> >                ; // Oh well, at least we tried to wait...
> >            }
> >        }
> >    }
> >
> >}
> >
> >Here are results for Linux (confirming File.lastModified()
> >rounds down to nearest second):
> > time 46, file 0
> > time 150, file 0
> > time 259, file 0
> > time 370, file 0
> > time 479, file 0
> > time 589, file 0
> > time 700, file 0
> > time 810, file 0
> > time 919, file 0
> > time 1029, file 1000
> > time 1139, file 1000
> > time 1250, file 1000
> > time 1359, file 1000
> > time 1469, file 1000
> > time 1579, file 1000
> > time 1690, file 1000
> > time 1799, file 1000
> > time 1909, file 1000
> > time 2020, file 2000
> > time 2129, file 2000
> > time 2240, file 2000
> > time 2350, file 2000
> > time 2459, file 2000
> > time 2569, file 2000
> > time 2680, file 2000
> >
> >dave

Here are some results from Windows XP using the Sun JDK 1.3.1_04 and the
Eclipse compiler.

time 443, file 443
 time 553, file 553
 time 646, file 646
 time 756, file 756
 time 865, file 865
 time 959, file 959
 time 1068, file 1068
 time 1162, file 1162
 time 1271, file 1271
 time 1365, file 1365
 time 1474, file 1474
 time 1568, file 1568
 time 1678, file 1678
 time 1771, file 1771
 time 1881, file 1881
 time 1974, file 1974
 time 2084, file 2084
 time 2178, file 2178
 time 2287, file 2287
 time 2381, file 2381
 time 2490, file 2490
 time 2584, file 2584
 time 2693, file 2693
 time 2803, file 2803
 time 2896, file 2896

Regards

Jonathan

Personal Email
jgossage@xxxxxxxx

Business Email
jonathan@xxxxxxxxxxxxxx



Back to the top