[Charlotte.PM] Help me tune this for speed

William McKee william at knowmad.com
Wed Jul 27 10:02:27 PDT 2005


On Tue, Jul 26, 2005 at 11:20:08PM -0400, drewhead at drewhead.org wrote:
> Here's an interesting problem I've hit recently [and totally diffrent from
> the recent template discussions :) ]

Thanks for the mind-bender. It is certainly a refreshing change from the
template discussions. I tried profiling the code following the article
at Perl.com[1]. Using the 301 edges, I had a 2.2Gb output file which was
way too much for my poor workstation. I dumbed down the input file to
just 30 edges which generated the results I've included below.

Basically, it looks like most of the time in the script is spent in
Math::Geometry::Planar. Even using Steven's version of the code, I still
see much the same results. It looks like you need to look at ways to
limit the calls to SegmentIntersection() or improve the algorithms in
Math::Geometry::Planar::SegmentIntersection.


HTH,
William

[1] http://www.perl.com/pub/a/2004/06/25/profiling.html


  william at zeus:~$ perl -d:DProf find_neighboor_edges.pl
  Found unique Edges = 870
   0 wallclock secs ( 0.02 usr +  0.00 sys =  0.02 CPU)
  Unintersected edges 158
   6 wallclock secs ( 5.83 usr +  0.14 sys =  5.97 CPU)
  william at zeus:~$ dprofpp
  Exporter::export_to_level has -1 unstacked calls in outer
  Exporter::export has -1 unstacked calls in outer
  POSIX::load_imports has 1 unstacked calls in outer
  POSIX::AUTOLOAD has -1 unstacked calls in outer
  Exporter::Heavy::heavy_export_to_level has 1 unstacked calls in outer
  Exporter::Heavy::heavy_export has 1 unstacked calls in outer
  Total Elapsed Time = 2.320667 Seconds
    User+System Time = 1.970667 Seconds
  Exclusive Times
  %Time ExclSec CumulS #Calls sec/call Csec/c  Name
   77.4   1.527  2.227  95534   0.0000 0.0000  Math::Geometry::Planar::SegmentInt
                                               ersection
   35.5   0.700  0.700 286602   0.0000 0.0000  Math::Geometry::Planar::Determinan
                                               t
   4.57   0.090  0.169      5   0.0180 0.0339  main::BEGIN
   1.01   0.020  0.030     19   0.0010 0.0016  YAML::BEGIN
   1.01   0.020  0.019     91   0.0002 0.0002  YAML::_parse_next_line
   0.51   0.010  0.010      1   0.0100 0.0100  Math::Geometry::Planar::GPC::boots
                                               trap
   0.51   0.010 -0.000      1   0.0100      -  POSIX::AUTOLOAD
   0.51   0.010  0.010      1   0.0100 0.0100  overload::BEGIN
   0.51   0.010  0.010      2   0.0050 0.0050  DynaLoader::BEGIN
   0.51   0.010  0.010     17   0.0006 0.0006  Exporter::import
   0.51   0.010  0.040      6   0.0017 0.0066  Math::Geometry::Planar::BEGIN
   0.00   0.000  0.000      1   0.0000 0.0000  Exporter::Heavy::heavy_export_to_l
                                               evel
   0.00   0.000  0.000      1   0.0000 0.0000  Exporter::Heavy::heavy_export
   0.00   0.000  0.000      1   0.0000 0.0000  POSIX::load_imports
   0.00       - -0.000      1        -      -  YAML::is_valid


-- 
Knowmad Services Inc.
http://www.knowmad.com


More information about the charlotte mailing list