Changeset 952d201 for doc


Ignore:
Timestamp:
Apr 14, 2017, 6:07:46 PM (8 years ago)
Author:
Peter A. Buhr <pabuhr@…>
Branches:
ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
Children:
4570131
Parents:
1504536
Message:

more evaluation material

Location:
doc/generic_types
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • doc/generic_types/evaluation/timing.gp

    r1504536 r952d201  
    1212set boxwidth 0.8
    1313
    14 set ylabel "milliseconds"
    1514set key top left reverse Left
    1615
     
    2120set linetype 4 lc rgb 'green'
    2221
     22set ylabel "milli-seconds"
     23set yrange [0:*] ;
     24
    2325set datafile separator ","
    2426plot for [COL=2:5] 'evaluation/timing.csv' using COL:xticlabels(1) title columnheader
  • doc/generic_types/generic_types.tex

    r1504536 r952d201  
    954954Since all these languages share a subset comprising most of standard C, maximal-performance benchmarks would show little runtime variance, other than in length and clarity of source code.
    955955Instead, the presented benchmarks show the costs of idiomatic use of each language's features to examine common usage.
    956 Figure~\ref{fig:MicroBenchmark} shows the benchmark tests for a generic stack based on a singly linked-list, a generic pair-data-structure, and a variadic @print@ routine similar to that in Section~\ref{sec:variadic-tuples}.
    957 The experiments are:
    958 \begin{enumerate}
    959 \item
    960 N stack pushes of int, where N = 40M
    961 \item
    962 copy int stack
    963 \item
    964 clear int stack
    965 \item
    966 N stack pops of int
    967 \end{enumerate}
     956Figure~\ref{fig:MicroBenchmark} shows the \CFA benchmark tests for a generic stack based on a singly linked-list, a generic pair-data-structure, and a variadic @print@ routine similar to that in Section~\ref{sec:variadic-tuples}.
     957The tests are similar for C and \CC.
     958The first two experiments use element types @int@ and @pair( _Bool, char)@, and push $N=40M$ elements on a generic stack, copy the stack, clear one of the stacks, and find the maximum value in the other stack.
     959The last experiment creates a file and prints $N=40M$ elements of type @int@ and @pair( _Bool, char)@ using a variadic print.
     960
    968961The structure of each implemented is: C with @void *@-based polymorphism, \CFA with the different presented features, \CC with templates, and \CC using only class inheritance for polymorphism, called \CCV.
    969962The \CCV variant illustrates an alternative object-oriented idiom where all objects inherit from a base @object@ class, mimicking a Java-like interface;
    970963hence runtime checks are necessary to safely down-cast objects.
    971 The most notable difference among the implementations is in memory layout of generic types: \CFA and \CC inline the stack and pair elements into corresponding list and pair nodes, while C and \CCV lack such a capability and store generic objects via pointers to separately-allocated objects instead.
    972 For the print benchmark, idiomatic printing is used: the C and \CFA variants use @stdio.h@, while the \CC and \CCV variants use @iostream@.
    973 Preliminary tests show this difference has little runtime effect.
     964The most notable difference among the implementations is in optimizations: \CFA and \CC inline the stack and pair elements into corresponding list and pair nodes, while the C and \CCV lack generic-type capability {\color{red}(AWKWARD) to store generic objects via pointers to separately-allocated objects}.
     965For the print benchmark, idiomatic printing is used: the C and \CFA variants used @cstdio.h@, while the \CC and \CCV variants used @iostream@.
     966Preliminary tests show the difference has little runtime effect.
    974967Finally, the C @rand@ function is used generate random numbers.
    975968
     
    984977        REPEAT_TIMED( "pop_int", max = max( max, pop( &t ) ); )
    985978
    986         stack(pair(_Bool, char)) s, t;
     979        stack(pair(_Bool, char)) s1, t1;
    987980        pair(_Bool, char) max = { (_Bool)0, '\0' };
    988         REPEAT_TIMED( "push_pair", push( &s, (pair(_Bool, char)){ 42, 42 } ); )
    989         TIMED( "copy_pair", t = s; )
    990         TIMED( "clear_pair", clear( &s ); )
    991         REPEAT_TIMED( "pop_pair", max = max( max, pop( &t ) ); )
     981        REPEAT_TIMED( "push_pair", push( &s1, (pair(_Bool, char)){ (_Bool)0, 'a' } ); )
     982        TIMED( "copy_pair", t1 = s1; )
     983        TIMED( "clear_pair", clear( &s1 ); )
     984        REPEAT_TIMED( "pop_pair", max = max( max, pop( &t1 ) ); )
    992985
    993986        FILE * out = fopen( "cfa-out.txt", "w" );
    994987        REPEAT_TIMED( "print_int", print( out, 42, ":", 42, "\n" ); )
    995         REPEAT_TIMED( "print_pair",
    996                  print( out, (pair(_Bool, char)){ 42, 42 }, ":", (pair(_Bool, char)){ 42, 42 }, "\n" ); )
     988        REPEAT_TIMED( "print_pair", print( out, (pair(_Bool, char)){ (_Bool)0, 'a' }, ":",
     989                                                         (pair(_Bool, char)){ (_Bool)0, 'a' }, "\n" ); )
    997990        fclose(out);
    998991}
     
    10141007\newcommand{\CT}[1]{\multicolumn{1}{c}{#1}}
    10151008\begin{tabular}{r|rrrr}
    1016                                                                         & \CT{C}        & \CT{\CFA}     & \CT{\CC}      &       \CT{\CCV}       \\ \hline
    1017 maximum memory usage (MB)                       & 10001         & 2501          & 2503          &       11253           \\
    1018 source code size (lines)                        & 301           & 224           & 188           &       437                     \\
     1009                                                        & \CT{C}        & \CT{\CFA}     & \CT{\CC}      &       \CT{\CCV}       \\ \hline
     1010maximum memory usage (MB)       & 10001         & 2501          & 2503          &       11253           \\
     1011source code size (lines)        & 301           & 224           & 188           &       437                     \\
    10191012redundant type annotations (lines)      & 46            & 3                     & 2                     &       15                      \\
    1020 binary size (KB)                                        & 18            & 234           & 18            &       42                      \\
     1013binary size (KB)                        & 18            & 234           & 18            &       42                      \\
    10211014\end{tabular}
    10221015\end{table}
     
    11261119
    11271120
     1121\bibliographystyle{ACM-Reference-Format}
     1122\bibliography{cfa}
     1123
     1124
    11281125\appendix
     1126
    11291127
    11301128\section{BenchMarks}
     
    11321130
    11331131TODO
    1134 
    1135 
    1136 \bibliographystyle{ACM-Reference-Format}
    1137 \bibliography{cfa}
    11381132
    11391133\end{document}
Note: See TracChangeset for help on using the changeset viewer.