diff --git a/examples/benchmark/benchmark.cpp b/examples/benchmark/benchmark.cpp index 5e07a0fc..cb82f198 100644 --- a/examples/benchmark/benchmark.cpp +++ b/examples/benchmark/benchmark.cpp @@ -1,450 +1,613 @@ -/* -This program binds 200 types, with 100 edges (type->type dependencies) and then injects the 100 X* types. -The whole process is then repeated 1000 times. -It was created with the following bash script: - -N=100 -M=1000 -( - echo "#include " - for n in `seq 1 $N` - do - echo "struct Y$n { INJECT(Y$n()) {} };" - echo "struct X$n { INJECT(X$n(Y$n)) {} };" - done - echo 'fruit::Component<' - for n in `seq 1 $[$N - 1]` - do - echo "X$n," - done - echo "X$N" - echo "> getComponent() { return fruit::createComponent(); }" - echo "int main() {" - echo "for (int i = 0; i < $M; i++) {" - echo "fruit::Injector<" - for n in `seq 1 $[$N - 1]` - do - echo "X$n," - done - echo "X$N" - echo "> injector(getComponent());" - for n in `seq 1 $N` - do - echo "injector.get();" - done - echo "}" - echo "return 0;" - echo "}" -)>main.cpp -*/ - #include -struct Y1 { INJECT(Y1()) {} }; -struct X1 { INJECT(X1(Y1)) {} }; -struct Y2 { INJECT(Y2()) {} }; -struct X2 { INJECT(X2(Y2)) {} }; -struct Y3 { INJECT(Y3()) {} }; -struct X3 { INJECT(X3(Y3)) {} }; -struct Y4 { INJECT(Y4()) {} }; -struct X4 { INJECT(X4(Y4)) {} }; -struct Y5 { INJECT(Y5()) {} }; -struct X5 { INJECT(X5(Y5)) {} }; -struct Y6 { INJECT(Y6()) {} }; -struct X6 { INJECT(X6(Y6)) {} }; -struct Y7 { INJECT(Y7()) {} }; -struct X7 { INJECT(X7(Y7)) {} }; -struct Y8 { INJECT(Y8()) {} }; -struct X8 { INJECT(X8(Y8)) {} }; -struct Y9 { INJECT(Y9()) {} }; -struct X9 { INJECT(X9(Y9)) {} }; -struct Y10 { INJECT(Y10()) {} }; -struct X10 { INJECT(X10(Y10)) {} }; -struct Y11 { INJECT(Y11()) {} }; -struct X11 { INJECT(X11(Y11)) {} }; -struct Y12 { INJECT(Y12()) {} }; -struct X12 { INJECT(X12(Y12)) {} }; -struct Y13 { INJECT(Y13()) {} }; -struct X13 { INJECT(X13(Y13)) {} }; -struct Y14 { INJECT(Y14()) {} }; -struct X14 { INJECT(X14(Y14)) {} }; -struct Y15 { INJECT(Y15()) {} }; -struct X15 { INJECT(X15(Y15)) {} }; -struct Y16 { INJECT(Y16()) {} }; -struct X16 { INJECT(X16(Y16)) {} }; -struct Y17 { INJECT(Y17()) {} }; -struct X17 { INJECT(X17(Y17)) {} }; -struct Y18 { INJECT(Y18()) {} }; -struct X18 { INJECT(X18(Y18)) {} }; -struct Y19 { INJECT(Y19()) {} }; -struct X19 { INJECT(X19(Y19)) {} }; -struct Y20 { INJECT(Y20()) {} }; -struct X20 { INJECT(X20(Y20)) {} }; -struct Y21 { INJECT(Y21()) {} }; -struct X21 { INJECT(X21(Y21)) {} }; -struct Y22 { INJECT(Y22()) {} }; -struct X22 { INJECT(X22(Y22)) {} }; -struct Y23 { INJECT(Y23()) {} }; -struct X23 { INJECT(X23(Y23)) {} }; -struct Y24 { INJECT(Y24()) {} }; -struct X24 { INJECT(X24(Y24)) {} }; -struct Y25 { INJECT(Y25()) {} }; -struct X25 { INJECT(X25(Y25)) {} }; -struct Y26 { INJECT(Y26()) {} }; -struct X26 { INJECT(X26(Y26)) {} }; -struct Y27 { INJECT(Y27()) {} }; -struct X27 { INJECT(X27(Y27)) {} }; -struct Y28 { INJECT(Y28()) {} }; -struct X28 { INJECT(X28(Y28)) {} }; -struct Y29 { INJECT(Y29()) {} }; -struct X29 { INJECT(X29(Y29)) {} }; -struct Y30 { INJECT(Y30()) {} }; -struct X30 { INJECT(X30(Y30)) {} }; -struct Y31 { INJECT(Y31()) {} }; -struct X31 { INJECT(X31(Y31)) {} }; -struct Y32 { INJECT(Y32()) {} }; -struct X32 { INJECT(X32(Y32)) {} }; -struct Y33 { INJECT(Y33()) {} }; -struct X33 { INJECT(X33(Y33)) {} }; -struct Y34 { INJECT(Y34()) {} }; -struct X34 { INJECT(X34(Y34)) {} }; -struct Y35 { INJECT(Y35()) {} }; -struct X35 { INJECT(X35(Y35)) {} }; -struct Y36 { INJECT(Y36()) {} }; -struct X36 { INJECT(X36(Y36)) {} }; -struct Y37 { INJECT(Y37()) {} }; -struct X37 { INJECT(X37(Y37)) {} }; -struct Y38 { INJECT(Y38()) {} }; -struct X38 { INJECT(X38(Y38)) {} }; -struct Y39 { INJECT(Y39()) {} }; -struct X39 { INJECT(X39(Y39)) {} }; -struct Y40 { INJECT(Y40()) {} }; -struct X40 { INJECT(X40(Y40)) {} }; -struct Y41 { INJECT(Y41()) {} }; -struct X41 { INJECT(X41(Y41)) {} }; -struct Y42 { INJECT(Y42()) {} }; -struct X42 { INJECT(X42(Y42)) {} }; -struct Y43 { INJECT(Y43()) {} }; -struct X43 { INJECT(X43(Y43)) {} }; -struct Y44 { INJECT(Y44()) {} }; -struct X44 { INJECT(X44(Y44)) {} }; -struct Y45 { INJECT(Y45()) {} }; -struct X45 { INJECT(X45(Y45)) {} }; -struct Y46 { INJECT(Y46()) {} }; -struct X46 { INJECT(X46(Y46)) {} }; -struct Y47 { INJECT(Y47()) {} }; -struct X47 { INJECT(X47(Y47)) {} }; -struct Y48 { INJECT(Y48()) {} }; -struct X48 { INJECT(X48(Y48)) {} }; -struct Y49 { INJECT(Y49()) {} }; -struct X49 { INJECT(X49(Y49)) {} }; -struct Y50 { INJECT(Y50()) {} }; -struct X50 { INJECT(X50(Y50)) {} }; -struct Y51 { INJECT(Y51()) {} }; -struct X51 { INJECT(X51(Y51)) {} }; -struct Y52 { INJECT(Y52()) {} }; -struct X52 { INJECT(X52(Y52)) {} }; -struct Y53 { INJECT(Y53()) {} }; -struct X53 { INJECT(X53(Y53)) {} }; -struct Y54 { INJECT(Y54()) {} }; -struct X54 { INJECT(X54(Y54)) {} }; -struct Y55 { INJECT(Y55()) {} }; -struct X55 { INJECT(X55(Y55)) {} }; -struct Y56 { INJECT(Y56()) {} }; -struct X56 { INJECT(X56(Y56)) {} }; -struct Y57 { INJECT(Y57()) {} }; -struct X57 { INJECT(X57(Y57)) {} }; -struct Y58 { INJECT(Y58()) {} }; -struct X58 { INJECT(X58(Y58)) {} }; -struct Y59 { INJECT(Y59()) {} }; -struct X59 { INJECT(X59(Y59)) {} }; -struct Y60 { INJECT(Y60()) {} }; -struct X60 { INJECT(X60(Y60)) {} }; -struct Y61 { INJECT(Y61()) {} }; -struct X61 { INJECT(X61(Y61)) {} }; -struct Y62 { INJECT(Y62()) {} }; -struct X62 { INJECT(X62(Y62)) {} }; -struct Y63 { INJECT(Y63()) {} }; -struct X63 { INJECT(X63(Y63)) {} }; -struct Y64 { INJECT(Y64()) {} }; -struct X64 { INJECT(X64(Y64)) {} }; -struct Y65 { INJECT(Y65()) {} }; -struct X65 { INJECT(X65(Y65)) {} }; -struct Y66 { INJECT(Y66()) {} }; -struct X66 { INJECT(X66(Y66)) {} }; -struct Y67 { INJECT(Y67()) {} }; -struct X67 { INJECT(X67(Y67)) {} }; -struct Y68 { INJECT(Y68()) {} }; -struct X68 { INJECT(X68(Y68)) {} }; -struct Y69 { INJECT(Y69()) {} }; -struct X69 { INJECT(X69(Y69)) {} }; -struct Y70 { INJECT(Y70()) {} }; -struct X70 { INJECT(X70(Y70)) {} }; -struct Y71 { INJECT(Y71()) {} }; -struct X71 { INJECT(X71(Y71)) {} }; -struct Y72 { INJECT(Y72()) {} }; -struct X72 { INJECT(X72(Y72)) {} }; -struct Y73 { INJECT(Y73()) {} }; -struct X73 { INJECT(X73(Y73)) {} }; -struct Y74 { INJECT(Y74()) {} }; -struct X74 { INJECT(X74(Y74)) {} }; -struct Y75 { INJECT(Y75()) {} }; -struct X75 { INJECT(X75(Y75)) {} }; -struct Y76 { INJECT(Y76()) {} }; -struct X76 { INJECT(X76(Y76)) {} }; -struct Y77 { INJECT(Y77()) {} }; -struct X77 { INJECT(X77(Y77)) {} }; -struct Y78 { INJECT(Y78()) {} }; -struct X78 { INJECT(X78(Y78)) {} }; -struct Y79 { INJECT(Y79()) {} }; -struct X79 { INJECT(X79(Y79)) {} }; -struct Y80 { INJECT(Y80()) {} }; -struct X80 { INJECT(X80(Y80)) {} }; -struct Y81 { INJECT(Y81()) {} }; -struct X81 { INJECT(X81(Y81)) {} }; -struct Y82 { INJECT(Y82()) {} }; -struct X82 { INJECT(X82(Y82)) {} }; -struct Y83 { INJECT(Y83()) {} }; -struct X83 { INJECT(X83(Y83)) {} }; -struct Y84 { INJECT(Y84()) {} }; -struct X84 { INJECT(X84(Y84)) {} }; -struct Y85 { INJECT(Y85()) {} }; -struct X85 { INJECT(X85(Y85)) {} }; -struct Y86 { INJECT(Y86()) {} }; -struct X86 { INJECT(X86(Y86)) {} }; -struct Y87 { INJECT(Y87()) {} }; -struct X87 { INJECT(X87(Y87)) {} }; -struct Y88 { INJECT(Y88()) {} }; -struct X88 { INJECT(X88(Y88)) {} }; -struct Y89 { INJECT(Y89()) {} }; -struct X89 { INJECT(X89(Y89)) {} }; -struct Y90 { INJECT(Y90()) {} }; -struct X90 { INJECT(X90(Y90)) {} }; -struct Y91 { INJECT(Y91()) {} }; -struct X91 { INJECT(X91(Y91)) {} }; -struct Y92 { INJECT(Y92()) {} }; -struct X92 { INJECT(X92(Y92)) {} }; -struct Y93 { INJECT(Y93()) {} }; -struct X93 { INJECT(X93(Y93)) {} }; -struct Y94 { INJECT(Y94()) {} }; -struct X94 { INJECT(X94(Y94)) {} }; -struct Y95 { INJECT(Y95()) {} }; -struct X95 { INJECT(X95(Y95)) {} }; -struct Y96 { INJECT(Y96()) {} }; -struct X96 { INJECT(X96(Y96)) {} }; -struct Y97 { INJECT(Y97()) {} }; -struct X97 { INJECT(X97(Y97)) {} }; -struct Y98 { INJECT(Y98()) {} }; -struct X98 { INJECT(X98(Y98)) {} }; -struct Y99 { INJECT(Y99()) {} }; -struct X99 { INJECT(X99(Y99)) {} }; -struct Y100 { INJECT(Y100()) {} }; -struct X100 { INJECT(X100(Y100)) {} }; + +struct X0 { INJECT(X0()) {} }; +struct X1 { INJECT(X1()) {} }; +struct X2 { INJECT(X2()) {} }; +struct X3 { INJECT(X3()) {} }; +struct X4 { INJECT(X4()) {} }; +struct X5 { INJECT(X5()) {} }; +struct X6 { INJECT(X6()) {} }; +struct X7 { INJECT(X7()) {} }; +struct X8 { INJECT(X8()) {} }; +struct X9 { INJECT(X9()) {} }; +struct X10 { INJECT(X10()) {} }; +struct X11 { INJECT(X11()) {} }; +struct X12 { INJECT(X12()) {} }; +struct X13 { INJECT(X13()) {} }; +struct X14 { INJECT(X14()) {} }; +struct X15 { INJECT(X15()) {} }; +struct X16 { INJECT(X16()) {} }; +struct X17 { INJECT(X17()) {} }; +struct X18 { INJECT(X18()) {} }; +struct X19 { INJECT(X19()) {} }; +struct X20 { INJECT(X20()) {} }; +struct X21 { INJECT(X21()) {} }; +struct X22 { INJECT(X22()) {} }; +struct X23 { INJECT(X23()) {} }; +struct X24 { INJECT(X24()) {} }; +struct X25 { INJECT(X25()) {} }; +struct X26 { INJECT(X26()) {} }; +struct X27 { INJECT(X27()) {} }; +struct X28 { INJECT(X28()) {} }; +struct X29 { INJECT(X29()) {} }; +struct X30 { INJECT(X30()) {} }; +struct X31 { INJECT(X31()) {} }; +struct X32 { INJECT(X32()) {} }; +struct X33 { INJECT(X33()) {} }; +struct X34 { INJECT(X34()) {} }; +struct X35 { INJECT(X35()) {} }; +struct X36 { INJECT(X36()) {} }; +struct X37 { INJECT(X37()) {} }; +struct X38 { INJECT(X38()) {} }; +struct X39 { INJECT(X39()) {} }; +struct X40 { INJECT(X40()) {} }; +struct X41 { INJECT(X41()) {} }; +struct X42 { INJECT(X42()) {} }; +struct X43 { INJECT(X43()) {} }; +struct X44 { INJECT(X44()) {} }; +struct X45 { INJECT(X45()) {} }; +struct X46 { INJECT(X46()) {} }; +struct X47 { INJECT(X47()) {} }; +struct X48 { INJECT(X48()) {} }; +struct X49 { INJECT(X49()) {} }; +struct X50 { INJECT(X50()) {} }; +struct X51 { INJECT(X51()) {} }; +struct X52 { INJECT(X52()) {} }; +struct X53 { INJECT(X53()) {} }; +struct X54 { INJECT(X54()) {} }; +struct X55 { INJECT(X55()) {} }; +struct X56 { INJECT(X56()) {} }; +struct X57 { INJECT(X57()) {} }; +struct X58 { INJECT(X58()) {} }; +struct X59 { INJECT(X59()) {} }; +struct X60 { INJECT(X60()) {} }; +struct X61 { INJECT(X61()) {} }; +struct X62 { INJECT(X62()) {} }; +struct X63 { INJECT(X63()) {} }; +struct X64 { INJECT(X64()) {} }; +struct X65 { INJECT(X65()) {} }; +struct X66 { INJECT(X66()) {} }; +struct X67 { INJECT(X67()) {} }; +struct X68 { INJECT(X68()) {} }; +struct X69 { INJECT(X69()) {} }; +struct X70 { INJECT(X70()) {} }; +struct X71 { INJECT(X71()) {} }; +struct X72 { INJECT(X72()) {} }; +struct X73 { INJECT(X73()) {} }; +struct X74 { INJECT(X74()) {} }; +struct X75 { INJECT(X75()) {} }; +struct X76 { INJECT(X76()) {} }; +struct X77 { INJECT(X77()) {} }; +struct X78 { INJECT(X78()) {} }; +struct X79 { INJECT(X79()) {} }; +struct X80 { INJECT(X80()) {} }; +struct X81 { INJECT(X81()) {} }; +struct X82 { INJECT(X82()) {} }; +struct X83 { INJECT(X83()) {} }; +struct X84 { INJECT(X84()) {} }; +struct X85 { INJECT(X85()) {} }; +struct X86 { INJECT(X86()) {} }; +struct X87 { INJECT(X87()) {} }; +struct X88 { INJECT(X88()) {} }; +struct X89 { INJECT(X89()) {} }; +struct X90 { INJECT(X90()) {} }; +struct X91 { INJECT(X91()) {} }; +struct X92 { INJECT(X92()) {} }; +struct X93 { INJECT(X93()) {} }; +struct X94 { INJECT(X94()) {} }; +struct X95 { INJECT(X95()) {} }; +struct X96 { INJECT(X96()) {} }; +struct X97 { INJECT(X97()) {} }; +struct X98 { INJECT(X98()) {} }; +struct X99 { INJECT(X99()) {} }; +struct X100 { INJECT(X100(X0, X12, X15, X26, X27, X45, X58, X63, X80, X83)) {} }; +struct X101 { INJECT(X101(X9, X23, X24, X39, X44, X49, X56, X61, X92, X93)) {} }; +struct X102 { INJECT(X102(X8, X11, X17, X30, X33, X45, X50, X53, X56, X95)) {} }; +struct X103 { INJECT(X103(X6, X19, X44, X61, X63, X64, X73, X89, X91, X96)) {} }; +struct X104 { INJECT(X104(X12, X18, X25, X32, X35, X72, X81, X88, X92, X101)) {} }; +struct X105 { INJECT(X105(X44, X47, X61, X67, X76, X79, X81, X88, X94, X103)) {} }; +struct X106 { INJECT(X106(X1, X6, X9, X22, X23, X33, X51, X72, X77, X82)) {} }; +struct X107 { INJECT(X107(X8, X38, X40, X65, X66, X74, X75, X86, X92, X105)) {} }; +struct X108 { INJECT(X108(X7, X9, X18, X48, X53, X55, X60, X67, X69, X98)) {} }; +struct X109 { INJECT(X109(X16, X32, X40, X49, X60, X68, X76, X88, X91, X107)) {} }; +struct X110 { INJECT(X110(X8, X19, X26, X27, X29, X65, X76, X83, X86, X98)) {} }; +struct X111 { INJECT(X111(X5, X29, X35, X38, X51, X54, X57, X62, X92, X104)) {} }; +struct X112 { INJECT(X112(X1, X2, X39, X48, X49, X55, X65, X78, X80, X105)) {} }; +struct X113 { INJECT(X113(X1, X10, X12, X15, X17, X30, X79, X87, X96, X104)) {} }; +struct X114 { INJECT(X114(X0, X1, X17, X62, X64, X69, X80, X89, X92, X109)) {} }; +struct X115 { INJECT(X115(X6, X29, X52, X65, X70, X82, X89, X93, X98, X113)) {} }; +struct X116 { INJECT(X116(X13, X31, X39, X47, X48, X58, X63, X70, X77, X99)) {} }; +struct X117 { INJECT(X117(X16, X40, X55, X59, X78, X79, X83, X91, X100, X106)) {} }; +struct X118 { INJECT(X118(X4, X16, X34, X53, X69, X74, X94, X96, X105, X116)) {} }; +struct X119 { INJECT(X119(X0, X19, X20, X22, X60, X76, X78, X83, X105, X112)) {} }; +struct X120 { INJECT(X120(X12, X14, X23, X24, X54, X60, X65, X70, X86, X105)) {} }; +struct X121 { INJECT(X121(X1, X4, X12, X16, X21, X31, X36, X54, X57, X96)) {} }; +struct X122 { INJECT(X122(X12, X13, X26, X37, X42, X54, X57, X64, X94, X105)) {} }; +struct X123 { INJECT(X123(X41, X63, X77, X79, X81, X90, X97, X103, X114, X120)) {} }; +struct X124 { INJECT(X124(X0, X10, X15, X45, X52, X54, X86, X90, X109, X110)) {} }; +struct X125 { INJECT(X125(X8, X11, X28, X32, X44, X45, X48, X92, X94, X112)) {} }; +struct X126 { INJECT(X126(X0, X27, X48, X64, X69, X72, X79, X97, X109, X124)) {} }; +struct X127 { INJECT(X127(X2, X3, X14, X29, X55, X79, X86, X92, X115, X122)) {} }; +struct X128 { INJECT(X128(X10, X35, X63, X66, X87, X98, X100, X107, X117, X119)) {} }; +struct X129 { INJECT(X129(X1, X9, X10, X16, X29, X62, X98, X117, X125, X128)) {} }; +struct X130 { INJECT(X130(X6, X29, X53, X81, X89, X90, X93, X105, X106, X108)) {} }; +struct X131 { INJECT(X131(X3, X9, X20, X36, X42, X53, X77, X84, X89, X119)) {} }; +struct X132 { INJECT(X132(X38, X41, X47, X87, X90, X99, X107, X119, X120, X126)) {} }; +struct X133 { INJECT(X133(X8, X11, X18, X28, X43, X45, X62, X90, X107, X109)) {} }; +struct X134 { INJECT(X134(X7, X23, X56, X69, X77, X80, X81, X86, X101, X103)) {} }; +struct X135 { INJECT(X135(X6, X13, X50, X69, X75, X80, X82, X93, X98, X106)) {} }; +struct X136 { INJECT(X136(X16, X41, X49, X63, X66, X78, X90, X103, X117, X122)) {} }; +struct X137 { INJECT(X137(X20, X21, X29, X30, X52, X53, X60, X66, X91, X131)) {} }; +struct X138 { INJECT(X138(X1, X10, X51, X53, X54, X73, X90, X96, X114, X115)) {} }; +struct X139 { INJECT(X139(X1, X2, X6, X19, X21, X47, X73, X76, X109, X126)) {} }; +struct X140 { INJECT(X140(X7, X18, X25, X38, X46, X55, X67, X90, X92, X103)) {} }; +struct X141 { INJECT(X141(X0, X28, X36, X47, X63, X66, X79, X101, X102, X126)) {} }; +struct X142 { INJECT(X142(X2, X13, X23, X27, X40, X49, X85, X104, X108, X137)) {} }; +struct X143 { INJECT(X143(X27, X36, X65, X68, X74, X76, X80, X93, X114, X116)) {} }; +struct X144 { INJECT(X144(X30, X37, X43, X81, X89, X90, X121, X125, X138, X143)) {} }; +struct X145 { INJECT(X145(X9, X25, X59, X82, X95, X99, X100, X114, X133, X137)) {} }; +struct X146 { INJECT(X146(X16, X44, X72, X93, X114, X120, X134, X135, X138, X141)) {} }; +struct X147 { INJECT(X147(X20, X28, X57, X73, X84, X94, X101, X107, X129, X137)) {} }; +struct X148 { INJECT(X148(X1, X60, X61, X73, X83, X90, X104, X107, X140, X143)) {} }; +struct X149 { INJECT(X149(X9, X23, X34, X39, X55, X68, X94, X97, X105, X114)) {} }; +struct X150 { INJECT(X150(X1, X19, X28, X35, X40, X55, X117, X125, X139, X149)) {} }; +struct X151 { INJECT(X151(X29, X40, X42, X56, X75, X77, X90, X120, X126, X143)) {} }; +struct X152 { INJECT(X152(X21, X27, X36, X38, X50, X71, X77, X102, X132, X133)) {} }; +struct X153 { INJECT(X153(X16, X23, X30, X58, X69, X74, X92, X106, X123, X139)) {} }; +struct X154 { INJECT(X154(X13, X20, X23, X54, X72, X82, X85, X96, X100, X119)) {} }; +struct X155 { INJECT(X155(X29, X57, X67, X78, X82, X85, X113, X114, X116, X121)) {} }; +struct X156 { INJECT(X156(X2, X6, X44, X66, X77, X88, X101, X107, X108, X141)) {} }; +struct X157 { INJECT(X157(X23, X38, X55, X56, X65, X82, X100, X106, X110, X150)) {} }; +struct X158 { INJECT(X158(X71, X75, X101, X105, X109, X118, X119, X137, X146, X150)) {} }; +struct X159 { INJECT(X159(X4, X9, X27, X59, X84, X87, X116, X124, X132, X154)) {} }; +struct X160 { INJECT(X160(X44, X66, X68, X81, X90, X125, X134, X135, X137, X147)) {} }; +struct X161 { INJECT(X161(X9, X24, X42, X47, X73, X118, X126, X132, X148, X149)) {} }; +struct X162 { INJECT(X162(X1, X10, X21, X37, X56, X70, X102, X106, X113, X161)) {} }; +struct X163 { INJECT(X163(X11, X31, X59, X60, X93, X98, X126, X134, X144, X151)) {} }; +struct X164 { INJECT(X164(X17, X18, X36, X39, X76, X106, X108, X140, X142, X160)) {} }; +struct X165 { INJECT(X165(X1, X47, X92, X93, X94, X101, X102, X125, X133, X146)) {} }; +struct X166 { INJECT(X166(X38, X40, X70, X97, X126, X128, X129, X133, X147, X164)) {} }; +struct X167 { INJECT(X167(X0, X1, X18, X20, X53, X79, X114, X128, X146, X165)) {} }; +struct X168 { INJECT(X168(X4, X5, X9, X84, X88, X96, X133, X143, X150, X152)) {} }; +struct X169 { INJECT(X169(X10, X59, X70, X81, X83, X87, X95, X97, X152, X165)) {} }; +struct X170 { INJECT(X170(X23, X26, X35, X74, X92, X93, X99, X144, X152, X156)) {} }; +struct X171 { INJECT(X171(X1, X3, X77, X88, X89, X108, X110, X116, X135, X159)) {} }; +struct X172 { INJECT(X172(X38, X44, X51, X55, X66, X74, X94, X132, X135, X159)) {} }; +struct X173 { INJECT(X173(X12, X22, X59, X66, X73, X83, X89, X105, X126, X137)) {} }; +struct X174 { INJECT(X174(X2, X7, X61, X64, X72, X99, X141, X149, X153, X169)) {} }; +struct X175 { INJECT(X175(X10, X29, X31, X84, X94, X96, X112, X124, X166, X170)) {} }; +struct X176 { INJECT(X176(X26, X33, X64, X74, X82, X105, X124, X141, X161, X172)) {} }; +struct X177 { INJECT(X177(X13, X19, X65, X91, X119, X120, X129, X142, X143, X161)) {} }; +struct X178 { INJECT(X178(X47, X49, X68, X99, X110, X141, X151, X169, X170, X172)) {} }; +struct X179 { INJECT(X179(X20, X23, X26, X28, X71, X74, X95, X101, X136, X170)) {} }; +struct X180 { INJECT(X180(X3, X15, X57, X65, X70, X92, X109, X111, X134, X140)) {} }; +struct X181 { INJECT(X181(X10, X14, X22, X23, X112, X116, X118, X130, X134, X152)) {} }; +struct X182 { INJECT(X182(X22, X28, X33, X48, X83, X84, X89, X129, X171, X180)) {} }; +struct X183 { INJECT(X183(X28, X35, X50, X75, X79, X87, X101, X127, X142, X179)) {} }; +struct X184 { INJECT(X184(X58, X60, X90, X105, X130, X150, X156, X162, X170, X179)) {} }; +struct X185 { INJECT(X185(X22, X44, X48, X91, X109, X111, X112, X140, X160, X179)) {} }; +struct X186 { INJECT(X186(X19, X38, X39, X41, X52, X83, X91, X155, X179, X183)) {} }; +struct X187 { INJECT(X187(X6, X19, X38, X48, X55, X78, X84, X104, X116, X178)) {} }; +struct X188 { INJECT(X188(X0, X19, X23, X75, X151, X152, X158, X163, X174, X186)) {} }; +struct X189 { INJECT(X189(X24, X52, X57, X76, X89, X96, X126, X128, X136, X140)) {} }; +struct X190 { INJECT(X190(X14, X18, X28, X84, X94, X133, X146, X160, X176, X188)) {} }; +struct X191 { INJECT(X191(X25, X38, X75, X102, X104, X128, X133, X136, X155, X180)) {} }; +struct X192 { INJECT(X192(X6, X54, X85, X97, X127, X128, X132, X158, X169, X187)) {} }; +struct X193 { INJECT(X193(X17, X20, X25, X30, X55, X70, X84, X94, X121, X172)) {} }; +struct X194 { INJECT(X194(X3, X22, X88, X116, X142, X146, X151, X152, X171, X191)) {} }; +struct X195 { INJECT(X195(X17, X71, X76, X77, X113, X130, X155, X163, X171, X185)) {} }; +struct X196 { INJECT(X196(X62, X76, X106, X116, X117, X134, X153, X155, X177, X190)) {} }; +struct X197 { INJECT(X197(X19, X42, X61, X73, X99, X101, X106, X126, X159, X181)) {} }; +struct X198 { INJECT(X198(X4, X15, X33, X48, X62, X87, X97, X99, X148, X160)) {} }; +struct X199 { INJECT(X199(X17, X20, X33, X57, X67, X69, X80, X99, X122, X136)) {} }; fruit::Component< -X1, -X2, -X3, -X4, -X5, -X6, -X7, -X8, -X9, -X10, -X11, -X12, -X13, -X14, -X15, -X16, -X17, -X18, -X19, -X20, -X21, -X22, -X23, -X24, -X25, -X26, -X27, -X28, -X29, -X30, -X31, -X32, -X33, -X34, -X35, -X36, -X37, -X38, -X39, -X40, -X41, -X42, -X43, -X44, -X45, -X46, -X47, -X48, -X49, -X50, -X51, -X52, -X53, -X54, -X55, -X56, -X57, -X58, -X59, -X60, -X61, -X62, -X63, -X64, -X65, -X66, -X67, -X68, -X69, -X70, -X71, -X72, -X73, -X74, -X75, -X76, -X77, -X78, -X79, -X80, -X81, -X82, -X83, -X84, -X85, -X86, -X87, -X88, -X89, -X90, -X91, -X92, -X93, -X94, -X95, -X96, -X97, -X98, -X99, -X100 +X0, +X1, +X2, +X3, +X4, +X5, +X6, +X7, +X8, +X9, +X10, +X11, +X12, +X13, +X14, +X15, +X16, +X17, +X18, +X19, +X20, +X21, +X22, +X23, +X24, +X25, +X26, +X27, +X28, +X29, +X30, +X31, +X32, +X33, +X34, +X35, +X36, +X37, +X38, +X39, +X40, +X41, +X42, +X43, +X44, +X45, +X46, +X47, +X48, +X49, +X50, +X51, +X52, +X53, +X54, +X55, +X56, +X57, +X58, +X59, +X60, +X61, +X62, +X63, +X64, +X65, +X66, +X67, +X68, +X69, +X70, +X71, +X72, +X73, +X74, +X75, +X76, +X77, +X78, +X79, +X80, +X81, +X82, +X83, +X84, +X85, +X86, +X87, +X88, +X89, +X90, +X91, +X92, +X93, +X94, +X95, +X96, +X97, +X98, +X99, +X100, +X101, +X102, +X103, +X104, +X105, +X106, +X107, +X108, +X109, +X110, +X111, +X112, +X113, +X114, +X115, +X116, +X117, +X118, +X119, +X120, +X121, +X122, +X123, +X124, +X125, +X126, +X127, +X128, +X129, +X130, +X131, +X132, +X133, +X134, +X135, +X136, +X137, +X138, +X139, +X140, +X141, +X142, +X143, +X144, +X145, +X146, +X147, +X148, +X149, +X150, +X151, +X152, +X153, +X154, +X155, +X156, +X157, +X158, +X159, +X160, +X161, +X162, +X163, +X164, +X165, +X166, +X167, +X168, +X169, +X170, +X171, +X172, +X173, +X174, +X175, +X176, +X177, +X178, +X179, +X180, +X181, +X182, +X183, +X184, +X185, +X186, +X187, +X188, +X189, +X190, +X191, +X192, +X193, +X194, +X195, +X196, +X197, +X198, +X199 > getComponent() { return fruit::createComponent(); } int main() { for (int i = 0; i < 1000; i++) { fruit::Injector< -X1, -X2, -X3, -X4, -X5, -X6, -X7, -X8, -X9, -X10, -X11, -X12, -X13, -X14, -X15, -X16, -X17, -X18, -X19, -X20, -X21, -X22, -X23, -X24, -X25, -X26, -X27, -X28, -X29, -X30, -X31, -X32, -X33, -X34, -X35, -X36, -X37, -X38, -X39, -X40, -X41, -X42, -X43, -X44, -X45, -X46, -X47, -X48, -X49, -X50, -X51, -X52, -X53, -X54, -X55, -X56, -X57, -X58, -X59, -X60, -X61, -X62, -X63, -X64, -X65, -X66, -X67, -X68, -X69, -X70, -X71, -X72, -X73, -X74, -X75, -X76, -X77, -X78, -X79, -X80, -X81, -X82, -X83, -X84, -X85, -X86, -X87, -X88, -X89, -X90, -X91, -X92, -X93, -X94, -X95, -X96, -X97, -X98, -X99, -X100 + +X0, +X1, +X2, +X3, +X4, +X5, +X6, +X7, +X8, +X9, +X10, +X11, +X12, +X13, +X14, +X15, +X16, +X17, +X18, +X19, +X20, +X21, +X22, +X23, +X24, +X25, +X26, +X27, +X28, +X29, +X30, +X31, +X32, +X33, +X34, +X35, +X36, +X37, +X38, +X39, +X40, +X41, +X42, +X43, +X44, +X45, +X46, +X47, +X48, +X49, +X50, +X51, +X52, +X53, +X54, +X55, +X56, +X57, +X58, +X59, +X60, +X61, +X62, +X63, +X64, +X65, +X66, +X67, +X68, +X69, +X70, +X71, +X72, +X73, +X74, +X75, +X76, +X77, +X78, +X79, +X80, +X81, +X82, +X83, +X84, +X85, +X86, +X87, +X88, +X89, +X90, +X91, +X92, +X93, +X94, +X95, +X96, +X97, +X98, +X99, +X100, +X101, +X102, +X103, +X104, +X105, +X106, +X107, +X108, +X109, +X110, +X111, +X112, +X113, +X114, +X115, +X116, +X117, +X118, +X119, +X120, +X121, +X122, +X123, +X124, +X125, +X126, +X127, +X128, +X129, +X130, +X131, +X132, +X133, +X134, +X135, +X136, +X137, +X138, +X139, +X140, +X141, +X142, +X143, +X144, +X145, +X146, +X147, +X148, +X149, +X150, +X151, +X152, +X153, +X154, +X155, +X156, +X157, +X158, +X159, +X160, +X161, +X162, +X163, +X164, +X165, +X166, +X167, +X168, +X169, +X170, +X171, +X172, +X173, +X174, +X175, +X176, +X177, +X178, +X179, +X180, +X181, +X182, +X183, +X184, +X185, +X186, +X187, +X188, +X189, +X190, +X191, +X192, +X193, +X194, +X195, +X196, +X197, +X198, +X199 > injector(getComponent()); +injector.get(); injector.get(); injector.get(); injector.get(); @@ -545,6 +708,105 @@ injector.get(); injector.get(); injector.get(); injector.get(); +injector.get(); +injector.get(); +injector.get(); +injector.get(); +injector.get(); +injector.get(); +injector.get(); +injector.get(); +injector.get(); +injector.get(); +injector.get(); +injector.get(); +injector.get(); +injector.get(); +injector.get(); +injector.get(); +injector.get(); +injector.get(); +injector.get(); +injector.get(); +injector.get(); +injector.get(); +injector.get(); +injector.get(); +injector.get(); +injector.get(); +injector.get(); +injector.get(); +injector.get(); +injector.get(); +injector.get(); +injector.get(); +injector.get(); +injector.get(); +injector.get(); +injector.get(); +injector.get(); +injector.get(); +injector.get(); +injector.get(); +injector.get(); +injector.get(); +injector.get(); +injector.get(); +injector.get(); +injector.get(); +injector.get(); +injector.get(); +injector.get(); +injector.get(); +injector.get(); +injector.get(); +injector.get(); +injector.get(); +injector.get(); +injector.get(); +injector.get(); +injector.get(); +injector.get(); +injector.get(); +injector.get(); +injector.get(); +injector.get(); +injector.get(); +injector.get(); +injector.get(); +injector.get(); +injector.get(); +injector.get(); +injector.get(); +injector.get(); +injector.get(); +injector.get(); +injector.get(); +injector.get(); +injector.get(); +injector.get(); +injector.get(); +injector.get(); +injector.get(); +injector.get(); +injector.get(); +injector.get(); +injector.get(); +injector.get(); +injector.get(); +injector.get(); +injector.get(); +injector.get(); +injector.get(); +injector.get(); +injector.get(); +injector.get(); +injector.get(); +injector.get(); +injector.get(); +injector.get(); +injector.get(); +injector.get(); } return 0; } diff --git a/examples/benchmark/generate_benchmark.cpp b/examples/benchmark/generate_benchmark.cpp new file mode 100644 index 00000000..9be0e1e7 --- /dev/null +++ b/examples/benchmark/generate_benchmark.cpp @@ -0,0 +1,93 @@ +/* + * Copyright 2014 Google Inc. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include +#include +#include +#include + +using namespace std; + +unsigned seed = std::chrono::system_clock::now().time_since_epoch().count(); +std::default_random_engine generator(seed); + +void add_node(int n, set deps) { + cout << "struct X" << n << " { INJECT(X" << n << "("; + for (auto i = deps.begin(), i_end = deps.end(); i != i_end; ++i) { + if (i != deps.begin()) { + cout << ", "; + } + cout << "X" << *i; + } + cout << ")) {} };" << endl; +} + +void print_type_list(int n) { + for (int i = 0; i < n; i++) { + if (i != 0) { + cout << ", "; + } + cout << endl; + cout << "X" << i; + } + cout << endl; +} + +set get_random_set(int N, int desired_size) { + assert(desired_size <= N); + set result; + std::uniform_int_distribution distribution(0, N - 1); + while (result.size() != desired_size) { + result.insert(distribution(generator)); + } + return result; +} + +int main() { + constexpr int num_types_with_no_deps = 100; + constexpr int num_types_with_deps = 100; + constexpr int num_deps = 10; + constexpr int num_loops = 1000; + static_assert(num_types_with_no_deps >= num_deps, "Not enough types with no deps"); + + cout << "#include " << endl << endl;; + + for (int i = 0; i < num_types_with_no_deps; i++) { + add_node(i, {}); + } + + for (int i = 0; i < num_types_with_deps; i++) { + add_node(i + num_types_with_no_deps, get_random_set(num_types_with_no_deps + i, num_deps)); + } + + cout << "fruit::Component<"; + print_type_list(num_types_with_no_deps + num_types_with_deps); + cout << "> getComponent() { return fruit::createComponent(); }" << endl; + cout << "int main() {" << endl; + cout << "for (int i = 0; i < " << num_loops << "; i++) {" << endl; + cout << "fruit::Injector<" << endl; + print_type_list(num_types_with_no_deps + num_types_with_deps); + cout << "> injector(getComponent());" << endl; + for (int i = 0; i < num_types_with_no_deps + num_types_with_deps; i++) { + cout << "injector.get();" << endl; + } + cout << "}" << endl; + cout << "return 0;" << endl; + cout << "}" << endl; + + return 0; +}