Changeset 79d4186
- Timestamp:
- Mar 6, 2018, 5:13:48 PM (7 years ago)
- 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:
- 14a3dad2
- Parents:
- 520145b
- Location:
- doc/papers/general/evaluation
- Files:
-
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
doc/papers/general/evaluation/Makefile
r520145b r79d4186 2 2 CFA = cfa 3 3 DEPFLAGS = -MMD -MP 4 ifdef DBG 5 CFLAGS = -O0 -ggdb -DN=500 6 else 4 7 CFLAGS = -O2 5 8 ifdef N 6 9 CFLAGS += -DN=$(N) 10 endif 7 11 endif 8 12 CXXFLAGS = $(CFLAGS) --std=c++14 … … 27 31 $(COMPILE.cfa) $(OUTPUT_OPTION) -c $< 28 32 29 COBJS = c-stack.o c-pair.o c- print.o c-bench.o33 COBJS = c-stack.o c-pair.o c-bench.o 30 34 CPPOBJS = cpp-bench.o 31 35 CPPVOBJS = cpp-vstack.o cpp-vbench.o 32 CFAOBJS = cfa-stack.o cfa-pair.o cfa- print.o cfa-bench.o36 CFAOBJS = cfa-stack.o cfa-pair.o cfa-bench.o 33 37 34 38 ${COBJS} ${CPPOBJS} ${CPPVOBJS} ${CFAOBJS} : ${MAKEFILE_NAME} 35 39 36 40 CFILES = bench.h $(patsubst c-bench.h,,$(COBJS:.o=.h)) $(COBJS:.o=.c) 37 CPPFILES = bench.hpp cpp-stack.hpp cpp-pair.hpp cpp-print.hpp$(CPPOBJS:.o=.cpp)38 CPPVFILES = bench.hpp object.hpp cpp-vprint.hpp$(patsubst cpp-vbench.hpp,,$(CPPVOBJS:.o=.hpp)) $(CPPVOBJS:.o=.cpp)41 CPPFILES = bench.hpp cpp-stack.hpp cpp-pair.hpp $(CPPOBJS:.o=.cpp) 42 CPPVFILES = bench.hpp object.hpp $(patsubst cpp-vbench.hpp,,$(CPPVOBJS:.o=.hpp)) $(CPPVOBJS:.o=.cpp) 39 43 CFAFILES = bench.h $(patsubst cfa-bench.h,,$(CFAOBJS:.o=.h)) $(CFAOBJS:.o=.c) 40 44 -
doc/papers/general/evaluation/bench.h
r520145b r79d4186 5 5 long ms_between(clock_t start, clock_t end) { return (end - start) / (CLOCKS_PER_SEC / 1000); } 6 6 7 #ifndef N 7 8 #define N 40000000 9 #endif 10 8 11 #define TIMED(name, code) { \ 9 12 volatile clock_t _start, _end; \ -
doc/papers/general/evaluation/bench.hpp
r520145b r79d4186 6 6 long ms_between(clock_t start, clock_t end) { return (end - start) / (CLOCKS_PER_SEC / 1000); } 7 7 8 #ifndef N 8 9 static const int N = 40000000; 10 #endif 11 9 12 #define TIMED(name, code) { \ 10 13 volatile clock_t _start, _end; \ -
doc/papers/general/evaluation/c-bench.c
r520145b r79d4186 4 4 #include "c-pair.h" 5 5 #include "c-stack.h" 6 #include "c-print.h"7 6 8 7 _Bool* new_bool( _Bool b ) { … … 39 38 40 39 int main(int argc, char** argv) { 41 FILE * out = fopen("/dev/null", "w");42 40 int maxi = 0, vali = 42; 43 41 struct stack si = new_stack(), ti; … … 50 48 if ( *xi > maxi ) { maxi = *xi; } 51 49 free(xi); ) 52 REPEAT_TIMED( "print_int", N/2, print( out, "dsds", vali, ":", vali, "\n" ); /***/ )53 50 54 51 struct pair * maxp = new_pair( new_bool(0), new_char('\0') ), … … 67 64 free_pair_bool_char( xp ); /***/ 68 65 } ) 69 REPEAT_TIMED( "print_pair", N/2, print( out, "pbcspbcs", *valp, ":", *valp, "\n" ); /***/ )70 66 free_pair_bool_char( maxp ); /***/ 71 67 free_pair_bool_char( valp ); /***/ 72 fclose(out);73 68 } -
doc/papers/general/evaluation/cfa-bench.c
r520145b r79d4186 1 #include <fstream>2 #include <stdlib>3 #include <stdbool.h>4 1 #include "bench.h" 5 2 #include "cfa-stack.h" 6 3 #include "cfa-pair.h" 7 #include "cfa-print.h"8 4 9 5 int main( int argc, char * argv[] ) { 10 ofstream out = { "/dev/null" };11 6 int max = 0, val = 42; 12 stack( int ) s , t;7 stack( int ) si, ti; 13 8 14 REPEAT_TIMED( "push_int", N, push( s , val ); )15 TIMED( "copy_int", t = s; )16 TIMED( "clear_int", clear( s ); )17 REPEAT_TIMED( "pop_int", N, int x = pop( t ); max = max( x, max ); )18 REPEAT_TIMED( "print_int", N/2, out | val | ':' | val | endl; )9 REPEAT_TIMED( "push_int", N, push( si, val ); ) 10 TIMED( "copy_int", ti = si; ) 11 TIMED( "clear_int", clear( si ); ) 12 REPEAT_TIMED( "pop_int", N, 13 int x = pop( ti ); if ( x > max ) max = x; ) 19 14 20 pair( _Bool, char ) max = { (_Bool) false, '\0' }, val = { (_Bool)true, 'a' };21 stack( pair( _Bool, char ) ) s , t;15 pair( _Bool, char ) max = { (_Bool)0 /***/, '\0' }, val = { (_Bool)1 /***/, 'a' }; 16 stack( pair( _Bool, char ) ) sp, tp; 22 17 23 REPEAT_TIMED( "push_pair", N, push( s , val ); )24 TIMED( "copy_pair", t = s; )25 TIMED( "clear_pair", clear( s ); )26 REPEAT_TIMED( "pop_pair", N, pair(_Bool, char) x = pop( t ); max = max( x, max ); )27 REPEAT_TIMED( "print_pair", N/2, out | val | ':' | val | endl; )18 REPEAT_TIMED( "push_pair", N, push( sp, val ); ) 19 TIMED( "copy_pair", tp = sp; ) 20 TIMED( "clear_pair", clear( sp ); ) 21 REPEAT_TIMED( "pop_pair", N, 22 pair(_Bool, char) x = pop( tp ); if ( x > max ) max = x; ) 28 23 } -
doc/papers/general/evaluation/cfa-pair.c
r520145b r79d4186 36 36 } 37 37 38 forall(otype R, otype S)39 forall(dtype ostype | ostream( ostype ) | { ostype & ?|?( ostype &, R ); ostype & ?|?( ostype &, S ); })40 ostype & ?|?( ostype & os, pair(R, S) p ) {41 return os | '[' | p.first | ',' | p.second | ']';42 } // ?|?38 // forall(otype R, otype S) 39 // forall(dtype ostype | ostream( ostype ) | { ostype & ?|?( ostype &, R ); ostype & ?|?( ostype &, S ); }) 40 // ostype & ?|?( ostype & os, pair(R, S) p ) { 41 // return os | '[' | p.first | ',' | p.second | ']'; 42 // } // ?|? -
doc/papers/general/evaluation/cfa-pair.h
r520145b r79d4186 30 30 int ?>=?(pair(R, S) p, pair(R, S) q); 31 31 32 forall(otype R, otype S)33 forall(dtype ostype | ostream( ostype ) | { ostype & ?|?( ostype &, pair(R, S)); })34 ostype & ?|?( ostype & os, pair(R, S) );32 // forall(otype R, otype S) 33 // forall(dtype ostype | ostream( ostype ) | { ostype & ?|?( ostype &, R ); ostype & ?|?( ostype &, S ); }) 34 // ostype & ?|?( ostype & os, pair(R, S) ); -
doc/papers/general/evaluation/cfa-stack.c
r520145b r79d4186 6 6 stack_node(T) * next; 7 7 }; 8 forall(otype T) void ?{}( stack_node(T) & node, T value, stack_node(T) * next ) {9 node.value = value;10 node.next = next;11 }12 8 13 9 forall(otype T) void ?{}( stack(T) & s ) { (s.head){ 0 }; } … … 16 12 stack_node(T) ** crnt = &s.head; 17 13 for ( stack_node(T) * next = t.head; next; next = next->next ) { 18 // *crnt = new( next->value, 0 ); 19 stack_node(T)* new_node = ((stack_node(T)*)malloc()); 20 (*new_node){ next->value }; /***/ 14 stack_node(T)* new_node = (stack_node(T)*)malloc(); /***/ 15 (*new_node){ next->value }; 21 16 *crnt = new_node; 22 stack_node(T) * acrnt = *crnt; 23 crnt = &acrnt->next; 17 crnt = &(*crnt)->next; 24 18 } 25 19 *crnt = 0; … … 38 32 39 33 forall(otype T) void push( stack(T) & s, T value ) { 40 // s.head = new( value, s.head ); 41 stack_node(T)* new_node = ((stack_node(T)*)malloc()); 42 (*new_node){ value, s.head }; /***/ 34 stack_node(T)* new_node = (stack_node(T)*)malloc(); /***/ 35 (*new_node){ value, s.head }; 43 36 s.head = new_node; 44 37 } … … 48 41 s.head = n->next; 49 42 T v = n->value; 50 delete( n ); 43 ^(*n){}; 44 free( n ); 51 45 return v; 52 46 } … … 56 50 stack_node(T) * crnt = next; 57 51 next = crnt->next; 58 delete( crnt ); 52 ^(*crnt){}; 53 free(crnt); 59 54 } 60 55 s.head = 0; -
doc/papers/general/evaluation/cpp-bench.cpp
r520145b r79d4186 1 1 #include <algorithm> 2 #include <fstream>3 2 #include "bench.hpp" 4 3 #include "cpp-stack.hpp" 5 4 #include "cpp-pair.hpp" 6 #include "cpp-print.hpp"7 5 8 6 int main(int argc, char** argv) { 9 std::ofstream out{"/dev/null"};10 7 int maxi = 0, vali = 42; 11 8 stack<int> si, ti; … … 15 12 TIMED( "clear_int", si.clear(); ) 16 13 REPEAT_TIMED( "pop_int", N, maxi = std::max( maxi, ti.pop() ); ) 17 REPEAT_TIMED( "print_int", N/2, print( out, vali, ":", vali, "\n" ); )18 14 19 15 pair<bool, char> maxp = { false, '\0' }, valp = { true, 'a' }; … … 24 20 TIMED( "clear_pair", sp.clear(); ) 25 21 REPEAT_TIMED( "pop_pair", N, maxp = std::max( maxp, tp.pop() ); ) 26 REPEAT_TIMED( "print_pair", N/2, print( out, valp, ":", valp, "\n" ); )27 22 } -
doc/papers/general/evaluation/cpp-vbench.cpp
r520145b r79d4186 1 1 #include <algorithm> 2 #include <fstream>3 2 #include "bench.hpp" 4 3 #include "cpp-vstack.hpp" 5 #include "cpp-vprint.hpp"6 4 #include "object.hpp" 7 5 8 6 int main(int argc, char** argv) { 9 std::ofstream out{"/dev/null"};10 7 integer maxi{ 0 }, vali{ 42 }; 11 8 stack si, ti; … … 15 12 TIMED( "clear_int", si.clear(); ) 16 13 REPEAT_TIMED( "pop_int", N, maxi = std::max( maxi, ti.pop()->as<integer>() ); /***/ ) 17 REPEAT_TIMED( "print_int", N/2, print( out, vali, c_string{":"}, vali, c_string{"\n"} ); )18 14 19 15 ptr<pair> maxp = make<pair>( make<boolean>(false), make<character>('\0') ); … … 27 23 ptr<pair> xp = as_ptr<pair>( tp.pop() ); /***/ 28 24 if ( *xp > *maxp ) { maxp = std::move(xp); } ) 29 REPEAT_TIMED( "print_pair", N/2, print( out, valp, c_string{":"}, valp, c_string{"\n"} ); )30 25 } -
doc/papers/general/evaluation/timing.dat
r520145b r79d4186 1 1 "400 million repetitions" "C" "\\CFA{}" "\\CC{}" "\\CC{obj}" 2 "push\nint" 3002 2459 1520 3305 3 "copy\nint" 2985 2057 1521 3152 4 "clear\nint" 1374 827 718 1469 5 "pop\nint" 1416 1221 717 5467 6 "print\nint" 5656 6758 3120 3121 7 "push\npair" 4214 2752 946 6826 8 "copy\npair" 6127 2105 993 7330 9 "clear\npair" 2881 885 711 3564 10 "pop\npair" 3046 5434 783 26538 11 "print\npair" 7514 10714 8717 16525 2 "push\nint" 2976 2225 1522 3266 3 "copy\nnt" 2932 7072 1526 3110 4 "clear\nint" 1380 731 750 1488 5 "pop\nint" 1444 1196 756 5156 6 "push\npair" 3695 2257 953 6840 7 "copy\npair" 6034 6650 994 7224 8 "clear\npair" 2832 848 742 3297 9 "pop\npair" 3009 5348 797 25235 10
Note: See TracChangeset
for help on using the changeset viewer.