src/main.cpp
// Draw a chart showing the average sort times
// for different numbers of elements in "SortChart.svg"
Draw a chart showing the average sort times
for different numbers of elements in "SortChart.svg"
Draw a chart showing the average sort times for different numbers of elements in " SortChart . svg "
static void drawSearchChart() {
    PPlot pplot;
    pplot.mPlotBackground.mTitle = "bst.contains() Versus std::find() on array";
    PlotData *theX1 = new PlotData ();
    PlotData *theY1 = new PlotData ();
    LineDataDrawer *theDataDrawer1 = new LineDataDrawer ();
    theDataDrawer1->mDrawPoint = false;
    theDataDrawer1->mDrawLine = true;
    LegendData *legend1 = new LegendData ();
    legend1->mName = "bst.contains()";
    legend1->mColor = PColor (200,0,100);
    PlotData *theX2 = new PlotData ();
    PlotData *theY2 = new PlotData ();
    LineDataDrawer *theDataDrawer2 = new LineDataDrawer ();
    theDataDrawer2->mDrawPoint = false;
    theDataDrawer2->mDrawLine = true;
    LegendData *legend2 = new LegendData ();
    legend2->mName = "std::find()";
    legend2->mColor = PColor (100,20,220);
    for (int i = 16; i <= 2048; i *= 2) {
        array<long long, 2> speeds = searchSpeed(i);
        theX1->push_back (i);
        theY1->push_back (speeds[0]);
        theX2->push_back (i);
        theY2->push_back (speeds[1]);
    }
    pplot.mPlotDataContainer.AddXYPlot (theX1, theY1, legend1, theDataDrawer1);
    pplot.mPlotDataContainer.AddXYPlot (theX2, theY2, legend2, theDataDrawer2);
    pplot.mMargins.mLeft = 100;
    pplot.mMargins.mTop = 50;
    pplot.mMargins.mRight = 50;
    pplot.mMargins.mBottom = 50;
    pplot.mGridInfo.mXGridOn = true;
    pplot.mGridInfo.mYGridOn = true;
    pplot.mYAxisSetup.mCrossOrigin = false;
    pplot.mXAxisSetup.mCrossOrigin = true;
    pplot.mXAxisSetup.mTickInfo.mTicksOn = true;
    pplot.mXAxisSetup.mLabel = "N";
    pplot.mYAxisSetup.mAutoScaleMin = false;
    pplot.mYAxisSetup.mAutoScaleMax = true;
    pplot.mYAxisSetup.mMin = 0;
    pplot.mXAxisSetup.mMin = 0;
    pplot.mYAxisSetup.mLabel = "Time (microseconds)";
    SVGPainter painter(800, 600);
    pplot.Draw(painter);
    painter.writeFile("SearchChart.svg");
    cout << "Wrote SVG SearchChart.svg" << endl;
}
static void drawSearchChart ( ) { PPlot pplot ; pplot . mPlotBackground . mTitle = " " ; PlotData * theX1 = new PlotData ( ) ; PlotData * theY1 = new PlotData ( ) ; LineDataDrawer * theDataDrawer1 = new LineDataDrawer ( ) ; theDataDrawer1 -> mDrawPoint = false ; theDataDrawer1 -> mDrawLine = true ; LegendData * legend1 = new LegendData ( ) ; legend1 -> mName = " " ; legend1 -> mColor = PColor ( 200 , 0 , 100 ) ; PlotData * theX2 = new PlotData ( ) ; PlotData * theY2 = new PlotData ( ) ; LineDataDrawer * theDataDrawer2 = new LineDataDrawer ( ) ; theDataDrawer2 -> mDrawPoint = false ; theDataDrawer2 -> mDrawLine = true ; LegendData * legend2 = new LegendData ( ) ; legend2 -> mName = " " ; legend2 -> mColor = PColor ( 100 , 20 , 220 ) ; for ( int i = 16 ; i <= 2048 ; i *= 2 ) { array < long long , 2 > speeds = searchSpeed ( i ) ; theX1 -> push_back ( i ) ; theY1 -> push_back ( speeds [ 0 ] ) ; theX2 -> push_back ( i ) ; theY2 -> push_back ( speeds [ 1 ] ) ; } pplot . mPlotDataContainer . AddXYPlot ( theX1 , theY1 , legend1 , theDataDrawer1 ) ; pplot . mPlotDataContainer . AddXYPlot ( theX2 , theY2 , legend2 , theDataDrawer2 ) ; pplot . mMargins . mLeft = 100 ; pplot . mMargins . mTop = 50 ; pplot . mMargins . mRight = 50 ; pplot . mMargins . mBottom = 50 ; pplot . mGridInfo . mXGridOn = true ; pplot . mGridInfo . mYGridOn = true ; pplot . mYAxisSetup . mCrossOrigin = false ; pplot . mXAxisSetup . mCrossOrigin = true ; pplot . mXAxisSetup . mTickInfo . mTicksOn = true ; pplot . mXAxisSetup . mLabel = " " ; pplot . mYAxisSetup . mAutoScaleMin = false ; pplot . mYAxisSetup . mAutoScaleMax = true ; pplot . mYAxisSetup . mMin = 0 ; pplot . mXAxisSetup . mMin = 0 ; pplot . mYAxisSetup . mLabel = " " ; SVGPainter painter ( 800 , 600 ) ; pplot . Draw ( painter ) ; painter . writeFile ( " " ) ; cout << " " << endl ; }
Draw a chart showing the average sort times
for different numbers of elements in "SortChart.svg"
Draw a chart showing the average sort times for different numbers of elements in " SortChart . svg "
// let us setup the first legend // just an rgb value // let us setup the first legend // just an rgb value //cout << "Generating SVG data..." << endl; // pplot.mYAxisSetup.mMax = 100;