use strict;
use warnings;
use Chart::Gnuplot;
my @x = ( 2 .. 50 );
my @y = map {
my $n = 0;
1 for sort { ++ $n; $a <=> $b } 1 .. $_;
$n
} @x;
my $chart = Chart::Gnuplot-> new(
gnuplot => 'gnuplot.exe',
terminal => 'dumb size 60, 30',
xrange => [ 0, 50 ],
yrange => [ 0, 50 ],
title => 'Number of comparisons vs pre-sorted array length',
);
my $dataset = Chart::Gnuplot::DataSet->new(
xdata => \@x,
ydata => \@y,
style => 'impulses',
);
__END__
Number of comparisons vs pre-sorted array length
50 +--------------------------------------------------+
| + + + + **|
| ****|
| ******|
| ********|
40 |-+ * **********|
| * ************|
| * **************|
| * ****************|
| *** ******************|
30 |-+ **** ********************|
| ***** **********************|
| ****** *************************|
| ******* ** *************************|
20 |-+ ******* **** *************************|
| ********* ****** *************************|
| **************** *************************|
| **************** *************************|
| ***************** *************************|
10 |-+ ****************** *************************|
| ******************** *************************|
| ******************** *************************|
| ********************* *************************|
| ********************** *************************|
0 +--------------------------------------------------+
0 10 20 30 40 50
|