Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: Mac OS X File IO Performance Issue?



> -----Original Message-----
> From: java-dev-bounces+rgenter=email@hidden
[mailto:java-dev-bounces+rgenter=email@hidden] On Behalf Of
William Groppe
> Sent: Friday, July 29, 2005 3:56 AM
> To: email@hidden
> Subject: Mac OS X File IO Performance Issue?
> 
>     private long testStraightFileIO(File fileToTest) throws Exception {
>         byte[] buffer = new byte[new
Long(fileToTest.length()).intValue()];
>         FileInputStream fis = new FileInputStream(fileToTest);
>         testStart = System.currentTimeMillis();
>         int bytesRead = 0;
>         int read = fis.read(buffer, 0, buffer.length);
>         bytesRead += read;
>         while(bytesRead < buffer.length && read != -1) {
>             read = fis.read(buffer, bytesRead, buffer.length - bytesRead);
>             bytesRead += read;
>         }
>         System.out.println("bytes read:"+bytesRead);
>         testEnd = System.currentTimeMillis();
>         return (testEnd - testStart);
>     }

One obvious change to make here: *don't* call System.out.println() *before*
getting your end time. Otherwise you're timing the time it takes to write
your "bytes read:" message to whatever stream System.out is pointing to
(file, console, whatever).

Rick
--
Rick Genter
email@hidden
(781) 771-9677 
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Java-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/java-dev/email@hidden

This email sent to email@hidden

References: 
 >Mac OS X File IO Performance Issue? (From: William Groppe <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.