Your code is extremely inefficient; stick to the stream read/write methods that use byte buffers: they are much faster because they avoid the cost of a method call for each byte. And if you use those methods exclusively, dropping the BufferedInput/OutputStream is almost certain to give better performance. Modifying your code to use an 8KB buffer I got this output from your code: BEFORE:
speed test a: 8361ms speed test b: 2405ms AFTER: speed test a: 123ms speed test b: 2ms Tom. 2008/11/22 ______ <[EMAIL PROTECTED]> > > Unfortunately that doesn't explain the speed problem. The processor > is almost 600MHz, that means it's taking 2400 CPU cycles *per byte* on > the read operation. An unbelievable overhead. Also I get 5MB/s both > up and down when connecting over USB, so the O/S (which is admittedly > running native code, not Dalvik bytecodes) can go much, much faster > than that, and it's not that the speed of flash memory is the > bottleneck either. The overhead of Dalvik is not *that* high, so > something else is going on that is making this about an order of > magnitude slower than it should be. Does anyone else have any ideas? > > > On Nov 22, 9:55 am, "Sunit Katkar" <[EMAIL PROTECTED]> wrote: > > Phones in general do not have super fast CPUs like laptop and desktops. > > Android runs on a phone CPU which is not very fast. Overall you will see > > that programs dont necessarily run at the same speed as on a laptop. > > - Sunit Katkarhttp://sunitkatkar.blogspot.com/- Android OS Tutorials > > > > On Fri, Nov 21, 2008 at 8:08 PM, ______ <[EMAIL PROTECTED]> wrote: > > > > > I measure the speed of copying files to/from the SD card at about 5MB/ > > > sec on my G1, however the following speed test tops out at about 250kB/ > > > sec read and 125kB/sec write. (The example shown writes to the > > > internal SD card, but writing to the removable card is about the same > > > speed.) Why is it so slow? (Using NIO channels to write whole arrays > > > of bytes doesn't speed it up by much...) > > > > > -- > > > > > long startTime = System.currentTimeMillis(); > > > BufferedOutputStream writer = new BufferedOutputStream(openFileOutput > > > ("speedtest", MODE_PRIVATE)); > > > int size = 1000000; > > > for (int i = 0; i < size; i++) > > > writer.write((byte) 0); > > > writer.close(); > > > Log.i("speedtest", "speed test a: " + (System.currentTimeMillis() - > > > startTime)); > > > startTime = System.currentTimeMillis(); > > > > > BufferedInputStream in = new BufferedInputStream(openFileInput > > > ("speedtest")); > > > for (int i = 0; i < size; i++) > > > in.read(); > > > in.close(); > > > > > Log.i("speedtest", "speed test b: " + (System.currentTimeMillis() - > > > startTime)); > > > startTime = System.currentTimeMillis(); > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~----------~----~----~----~------~----~------~--~---

