Changes in / [1504536:3fb7f5e]


Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • doc/generic_types/generic_types.tex

    r1504536 r3fb7f5e  
    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}
     956The benchmarks test 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}.
    968957The 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.
    969958The \CCV variant illustrates an alternative object-oriented idiom where all objects inherit from a base @object@ class, mimicking a Java-like interface;
     
    973962Preliminary tests show this difference has little runtime effect.
    974963Finally, the C @rand@ function is used generate random numbers.
    975 
    976 \begin{figure}
    977 \begin{lstlisting}[xleftmargin=3\parindentlnth,aboveskip=0pt,belowskip=0pt,numbers=left,numberstyle=\tt\small,numberblanklines=false]
    978 int main( int argc, char *argv[] ) {
    979         int max = 0;
    980         stack(int) s, t;
    981         REPEAT_TIMED( "push_int", push( &s, 42 ); )
    982         TIMED( "copy_int", t = s; )
    983         TIMED( "clear_int", clear( &s ); )
    984         REPEAT_TIMED( "pop_int", max = max( max, pop( &t ) ); )
    985 
    986         stack(pair(_Bool, char)) s, t;
    987         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 ) ); )
    992 
    993         FILE * out = fopen( "cfa-out.txt", "w" );
    994         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" ); )
    997         fclose(out);
    998 }
    999 \end{lstlisting}
    1000 \caption{Micro-Benchmark}
    1001 \label{fig:MicroBenchmark}
    1002 \end{figure}
    1003964
    1004965\begin{figure}
     
    10901051SETL~\cite{SETL} is a high-level mathematical programming language, with tuples being one of the primary data types.
    10911052Tuples in SETL allow subscripting, dynamic expansion, and multiple assignment.
    1092 C provides variadic functions through @va_list@ objects, but the programmer is responsible for managing the number of arguments and their types, so the mechanism is not type-safe.
     1053C provides variadic functions through @va_list@ objects, but the programmer is responsible for managing the number of arguments and their types.
    10931054KW-C~\cite{Buhr94a}, a predecessor of \CFA, introduced tuples to C as an extension of the C syntax, taking much of its inspiration from SETL.
    10941055The main contributions of that work were adding MRVF, tuple mass and multiple assignment, and record-field access.
Note: See TracChangeset for help on using the changeset viewer.