From: SourceForge.net <no...@so...> - 2013-03-31 13:57:01
|
Bugs item #3609590, was opened at 2013-03-31 06:57 Message generated for change (Tracker Item Submitted) made by You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=438935&aid=3609590&group_id=44253 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: Interactions Group: 4: Serious Status: Open Resolution: None Priority: 5 Private: No Submitted By: https://www.google.com/accounts () Assigned to: Nobody/Anonymous (nobody) Summary: class run from interactions can be very slow Initial Comment: Using algs4.jar from http://algs4.cs.princeton.edu/code/ this code is slow (1000 secs for reading a 8 MB file, runtime grows log2arithmic with file size): In synfile = new In(filename); Bag<String> synlines = new Bag<String>(); while (synfile.hasNextLine()) synlines.add(synfile.readLine()); but this is fast (1-2 sec): In synfile = new In(filename); ResizingArrayStack<String> synlines = new ResizingArrayStack<String>(); while (synfile.hasNextLine()) synlines.push(synfile.readLine()); However both of the codes are fast when run from opsystem command-line. The main difference is Bag uses a private Node class and creates a new one in each add() operation, ResizingArray doesn't. ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=438935&aid=3609590&group_id=44253 |