in reply to Improving dismal performance - Part 1

You might try getting it to terminate normally, at least on a small set of test data. Even if it's not doing its full and normal job, at least run through the code you want to profile.

—John

  • Comment on Re: Improving dismal performance - Part 1

Replies are listed 'Best First'.
Re^2: Improving dismal performance - Part 1
by PoorLuzer (Beadle) on May 12, 2009 at 21:10 UTC
    I ran it on a input of 20 "records" (1173 lines).

    Here is the output:

    Total Elapsed Time = 5.231984 Seconds User+System Time = 2.941984 Seconds Inclusive Times %Time ExclSec CumulS #Calls sec/call Csec/c Name 85.7 0.014 2.524 1037 0.0000 0.0024 Tie::File::PUSH 84.8 0.014 2.496 1037 0.0000 0.0024 Tie::File::SPLICE 83.1 0.133 2.447 1037 0.0001 0.0024 Tie::File::_splice 67.1 1.930 1.974 1037 0.0019 0.0019 Tie::File::_oadjust 10.4 0.038 0.308 2204 0.0000 0.0001 Tie::File::FETCH 9.18 0.020 0.270 2204 0.0000 0.0001 Tie::File::_fetch 8.19 0.019 0.241 1037 0.0000 0.0002 Tie::File::_mtwrite 6.42 0.110 0.189 5 0.0220 0.0377 main::BEGIN 5.20 0.069 0.153 1037 0.0001 0.0001 Tie::File::_downcopy 4.08 0.120 0.120 2074 0.0001 0.0001 Tie::File::_write_record 3.33 0.034 0.098 2204 0.0000 0.0000 Tie::File::Cache::lookup 2.92 0.038 0.086 1172 0.0000 0.0001 Tie::File::Cache::insert 2.69 0.049 0.079 2074 0.0000 0.0000 Tie::File::_cache_flush 2.65 0.078 0.078 2348 0.0000 0.0000 Tie::File::_read_record 2.41 0.039 0.071 3134 0.0000 0.0000 Tie::File::FETCHSIZE

    Obviously, Tie::File::PUSH is killing me, and that is what I thought from the beginning as well, but it seems there's no way to do away with this, atleast with with my simple approach?

    Any pointers?

      Well, yea, Acolyte. The only thing you are doing with @arrayOfOther is pushing to it. So, forget that array and tie completely. Instead, open a file for writing, and replace the push with a print to that file.

      I'm supposing that there is a useful reason for tieing the input array, rather than just reading the whole thing into a real array object: the file is too large. So I'd not change that one unless it is a performance problem too.

      But the @arrayOfOther is only referenced 3 times in the code, and is a push in all cases. That's not a proper use of an array. That's an output stream.

      —John