diff --git a/Makefile b/Makefile
index e9ef456bf..81d04425f 100644
--- a/Makefile
+++ b/Makefile
@@ -118,10 +118,18 @@ docs-open: ## Open odoc docs with default web browser
.PHONY: docs-serve
docs-serve: docs docs-open ## Open odoc docs with default web browser
+.PHONY: build-bench
+build-bench: ## Run benchmark
+ $(DUNE) build bench --profile=release
+
.PHONY: bench
-bench: ## Run benchmark
+bench: build-bench ## Run benchmark
$(DUNE) exec bench/main.exe --profile=release --display-separate-messages --no-print-directory
.PHONY: bench-watch
-bench-watch: ## Run benchmark in watch mode
+bench-watch: build-bench ## Run benchmark in watch mode
$(DUNE) exec bench/main.exe --profile=release --display-separate-messages --no-print-directory --watch
+
+.PHONY: once
+once: build-bench ## Run benchmark once
+ @time _build/default/bench/once.exe
diff --git a/bench/.keep b/bench/.keep
new file mode 100644
index 000000000..e69de29bb
diff --git a/bench/dune b/bench/dune
index 6b3381043..a10d3d89f 100644
--- a/bench/dune
+++ b/bench/dune
@@ -1,3 +1,16 @@
(executable
- (name bench)
- (libraries core_bench core_unix.command_unix))
+ (name main)
+ (modules main)
+ (libraries
+ core_bench
+ server-reason-react.react
+ server-reason-react.reactDom)
+ (preprocess
+ (pps server-reason-react.ppx)))
+
+(executable
+ (name once)
+ (modules once)
+ (libraries server-reason-react.react server-reason-react.reactDom)
+ (preprocess
+ (pps server-reason-react.ppx)))
diff --git a/bench/main.re b/bench/main.re
index 2db43f050..f39efb83b 100644
--- a/bench/main.re
+++ b/bench/main.re
@@ -1,37 +1,44 @@
-open Core;
-open Core_bench;
+module Bench = Core_bench.Bench;
-module App = {
+module TinyApp = {
[@react.component]
let make = () => {
-
-
- {React.string("Home of the demos")}
-
-
-
;
+
+
+ {React.string("Hello World")}
+ {React.string("This is an example")}
+
+ ;
};
};
-let bench_static =
- Bench.Test.create(~name="Parse static", () =>
- ReactDOM.renderToStaticMarkup()
+let bench_static_markup_with_simple_app =
+ Bench.Test.create(~name="bench_static_markup_with_simple_app", () =>
+ ReactDOM.renderToStaticMarkup()
);
-Command_unix.run @@ Bench.make_command([bench_static]);
+let main = tests => {
+ Printf.printf("\n\nRunning benchmarks\n");
+ Bench.bench(
+ ~analysis_configs=
+ Bench.Analysis_config.default
+ |> List.map(
+ Bench.Analysis_config.with_error_estimation(
+ ~bootstrap_trials=10000,
+ ),
+ ),
+ ~run_config=
+ Bench.Run_config.create(
+ ~quota=Bench.Quota.Num_calls(100000),
+ ~stabilize_gc_between_runs=true,
+ ~fork_each_benchmark=true,
+ (),
+ ),
+ ~save_to_file=
+ measurement =>
+ "bench/results/" ++ Bench.Measurement.name(measurement) ++ ".csv",
+ tests,
+ );
+};
+
+main([bench_static_markup_with_simple_app]);
diff --git a/bench/once.re b/bench/once.re
new file mode 100644
index 000000000..e7d849b43
--- /dev/null
+++ b/bench/once.re
@@ -0,0 +1,13 @@
+module TinyApp = {
+ [@react.component]
+ let make = () => {
+
+
+ {React.string("Hello World")}
+ {React.string("This is an example")}
+
+ ;
+ };
+};
+
+print_endline(ReactDOM.renderToStaticMarkup());
diff --git a/bench/results/bench_static_markup_with_simple_app.csv b/bench/results/bench_static_markup_with_simple_app.csv
new file mode 100644
index 000000000..6f4b7b971
--- /dev/null
+++ b/bench/results/bench_static_markup_with_simple_app.csv
@@ -0,0 +1,377 @@
+# bench_static_markup_with_simple_app
+runs,cycles,nanos,compactions,minor_allocated,major_allocated,promoted,major_collections,minor_collections
+0,0,2145,0,4,0,0,0,0
+1,734125,735998,0,39,0,0,0,0
+2,1750,1907,0,75,0,0,0,0
+3,1291,953,0,110,0,0,0,0
+4,3042,2861,0,145,0,0,0,0
+5,2041,1907,0,181,0,0,0,0
+6,2167,1907,0,216,0,0,0,0
+7,2625,3099,0,251,0,0,0,0
+8,3000,3099,0,287,0,0,0,0
+9,3083,4053,0,322,0,0,0,0
+10,3542,4053,0,358,0,0,0,0
+11,3834,3099,0,393,0,0,0,0
+12,4708,5006,0,428,0,0,0,0
+13,4375,4053,0,464,0,0,0,0
+14,4875,5006,0,499,0,0,0,0
+15,7000,6914,0,534,0,0,0,0
+16,5375,5722,0,570,0,0,0,0
+17,5667,6198,0,605,0,0,0,0
+18,6166,6198,0,641,0,0,0,0
+19,6334,5960,0,676,0,0,0,0
+20,6792,6914,0,711,0,0,0,0
+21,7000,6914,0,747,0,0,0,0
+22,8750,9059,0,782,0,0,0,0
+23,7709,8106,0,817,0,0,0,0
+24,8000,8344,0,853,0,0,0,0
+25,8208,8344,0,888,0,0,0,0
+26,8708,8106,0,924,0,0,0,0
+27,8875,7867,0,959,0,0,0,0
+28,9458,10251,0,994,0,0,0,0
+29,12667,13113,0,1030,0,0,0,0
+30,10583,10013,0,1065,0,0,0,0
+31,10209,10013,0,1100,0,0,0,0
+32,10541,10967,0,1136,0,0,0,0
+33,10833,10967,0,1171,0,0,0,0
+34,11292,10967,0,1207,0,0,0,0
+35,11625,10967,0,1242,0,0,0,0
+36,13708,13828,0,1277,0,0,0,0
+37,12333,12874,0,1313,0,0,0,0
+38,12417,12159,0,1348,0,0,0,0
+39,12750,13113,0,1383,0,0,0,0
+40,13042,13113,0,1419,0,0,0,0
+41,19416,19073,0,1454,0,0,0,0
+42,15542,15020,0,1490,0,0,0,0
+43,14625,13828,0,1525,0,0,0,0
+44,17042,16927,0,1560,0,0,0,0
+45,14916,15020,0,1596,0,0,0,0
+46,15625,15974,0,1631,0,0,0,0
+47,15500,15735,0,1666,0,0,0,0
+48,16166,16212,0,1702,0,0,0,0
+49,16333,16212,0,1737,0,0,0,0
+50,16708,16927,0,1773,0,0,0,0
+51,21375,20980,0,1808,0,0,0,0
+52,17167,17166,0,1843,0,0,0,0
+53,17750,18119,0,1879,0,0,0,0
+54,17917,17881,0,1914,0,0,0,0
+55,18417,18119,0,1949,0,0,0,0
+56,18584,19073,0,1985,0,0,0,0
+57,19041,18835,0,2020,0,0,0,0
+58,21000,20980,0,2056,0,0,0,0
+59,19500,20027,0,2091,0,0,0,0
+60,19959,19788,0,2126,0,0,0,0
+61,20000,20027,0,2162,0,0,0,0
+62,20542,20980,0,2197,0,0,0,0
+63,21000,21219,0,2232,0,0,0,0
+64,21166,20980,0,2268,0,0,0,0
+65,23167,24080,0,2303,0,0,0,0
+66,21875,22172,0,2339,0,0,0,0
+67,22167,23126,0,2374,0,0,0,0
+68,22583,21934,0,2409,0,0,0,0
+69,22917,23126,0,2445,0,0,0,0
+70,23250,23126,0,2480,0,0,0,0
+71,23375,22888,0,2515,0,0,0,0
+72,24083,23841,0,2551,0,0,0,0
+73,28375,29087,0,2586,0,0,0,0
+74,24875,25033,0,2622,0,0,0,0
+75,24750,25033,0,2657,0,0,0,0
+76,25125,25033,0,2692,0,0,0,0
+77,25542,25033,0,2728,0,0,0,0
+78,25750,25987,0,2763,0,0,0,0
+79,26417,25749,0,2798,0,0,0,0
+80,30917,30994,0,2834,0,0,0,0
+81,26750,26702,0,2869,0,0,0,0
+82,27250,27179,0,2905,0,0,0,0
+83,27416,27894,0,2940,0,0,0,0
+84,27750,27894,0,2975,0,0,0,0
+85,27958,27894,0,3011,0,0,0,0
+86,29500,30040,0,3046,0,0,0,0
+87,31375,30994,0,3081,0,0,0,0
+88,29666,30279,0,3117,0,0,0,0
+89,29417,28848,0,3152,0,0,0,0
+90,33250,32901,0,3188,0,0,0,0
+91,30584,34093,0,3223,0,0,0,0
+92,30292,30994,0,3258,0,0,0,0
+93,31084,30994,0,3294,0,0,0,0
+94,33458,33855,0,3329,0,0,0,0
+95,31459,30994,0,3364,0,0,0,0
+96,31541,31948,0,3400,0,0,0,0
+97,32000,32186,0,3435,0,0,0,0
+98,32250,32901,0,3471,0,0,0,0
+99,37583,37908,0,3506,0,0,0,0
+100,32375,32186,0,3541,0,0,0,0
+101,32833,33140,0,3577,0,0,0,0
+102,33084,33140,0,3612,0,0,0,0
+103,33500,32901,0,3647,0,0,0,0
+104,33833,33855,0,3683,0,0,0,0
+105,33833,34093,0,3718,0,0,0,0
+106,34333,34093,0,3754,0,0,0,0
+107,34542,35047,0,3789,0,0,0,0
+108,35875,36001,0,3824,0,0,0,0
+109,37084,36954,0,3860,0,0,0,0
+110,35750,36001,0,3895,0,0,0,0
+111,36209,35762,0,3930,0,0,0,0
+112,35917,36239,0,3966,0,0,0,0
+113,36584,36954,0,4001,0,0,0,0
+114,36959,37193,0,4037,0,0,0,0
+115,47000,46968,0,4072,0,0,0,0
+116,39333,38862,0,4107,0,0,0,0
+117,37666,38146,0,4143,0,0,0,0
+118,38584,38862,0,4178,0,0,0,0
+119,38333,38146,0,4213,0,0,0,0
+120,38750,38862,0,4249,0,0,0,0
+121,38917,38862,0,4284,0,0,0,0
+122,41500,41007,0,4320,0,0,0,0
+123,41416,41007,0,4355,0,0,0,0
+124,39958,39815,0,4390,0,0,0,0
+125,40417,40769,0,4426,0,0,0,0
+126,40625,41007,0,4461,0,0,0,0
+127,40916,41007,0,4496,0,0,0,0
+128,41250,40769,0,4532,0,0,0,0
+129,41833,42200,0,4567,0,0,0,0
+130,42041,41961,0,4603,0,0,0,0
+131,42333,41961,0,4638,0,0,0,0
+132,43125,42915,0,4673,0,0,0,0
+133,43458,44107,0,4709,0,0,0,0
+134,43000,43869,0,4744,0,0,0,0
+135,43666,43869,0,4779,0,0,0,0
+136,43792,44107,0,4815,0,0,0,0
+137,44458,45061,0,4850,0,0,0,0
+138,49292,48875,0,4886,0,0,0,0
+139,44667,45061,0,4921,0,0,0,0
+140,45042,44822,0,4956,0,0,0,0
+141,45667,44822,0,4992,0,0,0,0
+142,45583,45061,0,5027,0,0,0,0
+143,46083,46968,0,5062,0,0,0,0
+144,46250,46014,0,5098,0,0,0,0
+145,48417,47922,0,5133,0,0,0,0
+146,47000,47683,0,5169,0,0,0,0
+147,47333,46968,0,5204,0,0,0,0
+148,47917,48160,0,5239,0,0,0,0
+149,48000,47922,0,5275,0,0,0,0
+150,48250,49352,0,5310,0,0,0,0
+151,48541,48875,0,5345,0,0,0,0
+152,51417,51975,0,5381,0,0,0,0
+153,49250,49829,0,5416,0,0,0,0
+154,49875,50067,0,5452,0,0,0,0
+155,49875,50306,0,5487,0,0,0,0
+156,50500,51021,0,5522,0,0,0,0
+157,50708,50783,0,5558,0,0,0,0
+158,57625,57935,0,5593,0,0,0,0
+159,51792,51975,0,5628,0,0,0,0
+160,51541,51975,0,5664,0,0,0,0
+161,52833,52928,0,5699,0,0,0,0
+162,52125,51975,0,5735,0,0,0,0
+163,52917,55789,0,5770,0,0,0,0
+164,53958,53882,0,5805,0,0,0,0
+165,53417,52928,0,5841,0,0,0,0
+166,53458,54121,0,5876,0,0,0,0
+167,55417,55074,0,5911,0,0,0,0
+168,54000,53882,0,5947,0,0,0,0
+169,54375,54121,0,5982,0,0,0,0
+170,54833,54836,0,6018,0,0,0,0
+171,54834,54836,0,6053,0,0,0,0
+172,55916,56028,0,6088,0,0,0,0
+173,55584,55789,0,6124,0,0,0,0
+174,57500,57697,0,6159,0,0,0,0
+175,56125,56028,0,6194,0,0,0,0
+176,56583,56743,0,6230,0,0,0,0
+177,57084,57220,0,6265,0,0,0,0
+178,57292,56982,0,6301,0,0,0,0
+179,57750,57935,0,6336,0,0,0,0
+180,58208,58889,0,6371,0,0,0,0
+181,60042,59843,0,6407,0,0,0,0
+182,58416,58889,0,6442,0,0,0,0
+183,59167,60081,0,6477,0,0,0,0
+184,59292,60081,0,6513,0,0,0,0
+185,59833,59127,0,6548,0,0,0,0
+186,59834,59127,0,6584,0,0,0,0
+187,64042,63896,0,6619,0,0,0,0
+188,62791,61988,0,6654,0,0,0,0
+189,65291,65088,0,6690,0,0,0,0
+190,64416,64134,0,6725,0,0,0,0
+191,61250,61035,0,6760,0,0,0,0
+192,62375,61988,0,6796,0,0,0,0
+193,62083,62227,0,6831,0,0,0,0
+194,63417,63896,0,6867,0,0,0,0
+195,66292,66041,0,6902,0,0,0,0
+196,69500,70095,0,6937,0,0,0,0
+197,71916,71763,0,6973,0,0,0,0
+198,64750,65088,0,7008,0,0,0,0
+199,63959,63896,0,7043,0,0,0,0
+200,65209,65088,0,7079,0,0,0,0
+202,65083,65088,0,7150,0,0,0,0
+204,70083,69856,0,7220,0,0,0,0
+206,74542,75101,0,7291,0,0,0,0
+208,68833,68902,0,7362,0,0,0,0
+210,72125,72002,0,7433,0,0,0,0
+212,69666,70095,0,7503,0,0,0,0
+214,80125,79870,0,7574,0,0,0,0
+216,71417,70810,0,7645,0,0,0,0
+218,76958,77962,0,7716,0,0,0,0
+220,89291,89168,0,7786,0,0,0,0
+222,92792,92983,0,7857,0,0,0,0
+224,93416,93936,0,7928,0,0,0,0
+226,89917,90122,0,7999,0,0,0,0
+228,87167,87022,0,8069,0,0,0,0
+230,81959,82015,0,8140,0,0,0,0
+232,87834,88214,0,8211,0,0,0,0
+234,93541,93936,0,8282,0,0,0,0
+236,86833,87022,0,8352,0,0,0,0
+238,84041,83923,0,8423,0,0,0,0
+240,82834,82254,0,8494,0,0,0,0
+242,85625,84877,0,8565,0,0,0,0
+244,78458,79154,0,8635,0,0,0,0
+246,83458,83923,0,8706,0,0,0,0
+248,84583,84161,0,8777,0,0,0,0
+250,82458,82969,0,8848,0,0,0,0
+252,81125,81062,0,8918,0,0,0,0
+254,83458,83208,0,8989,0,0,0,0
+256,87500,87022,0,9060,0,0,0,0
+258,83166,83923,0,9131,0,0,0,0
+260,83375,84161,0,9201,0,0,0,0
+262,88625,87976,0,9272,0,0,0,0
+264,85000,84877,0,9343,0,0,0,0
+266,85792,86069,0,9414,0,0,0,0
+268,89625,90122,0,9484,0,0,0,0
+270,86667,86784,0,9555,0,0,0,0
+272,87542,87022,0,9626,0,0,0,0
+274,88583,87976,0,9697,0,0,0,0
+276,93375,92744,0,9767,0,0,0,0
+278,89458,89883,0,9838,0,0,0,0
+280,89958,90122,0,9909,0,0,0,0
+282,91208,91075,0,9980,0,0,0,0
+284,91417,92029,0,10050,0,0,0,0
+286,91875,91791,0,10121,0,0,0,0
+288,92708,92744,0,10192,0,0,0,0
+290,95542,96082,0,10263,0,0,0,0
+292,94333,93936,0,10333,0,0,0,0
+294,94583,97990,0,10404,0,0,0,0
+296,95500,96082,0,10475,0,0,0,0
+298,108042,109195,0,10546,0,0,0,0
+300,96917,96797,0,10616,0,0,0,0
+303,97333,97036,0,10722,0,0,0,0
+306,102375,102996,0,10829,0,0,0,0
+309,101375,100851,0,10935,0,0,0,0
+312,106584,105857,0,11041,0,0,0,0
+315,100958,103950,0,11147,0,0,0,0
+318,103000,104904,0,11253,0,0,0,0
+321,107834,108003,0,11359,0,0,0,0
+324,106333,107049,0,11465,0,0,0,0
+327,113917,113964,0,11571,0,0,0,0
+330,108125,108003,0,11678,0,0,0,0
+333,110750,111103,0,11784,0,0,0,0
+336,108000,108003,0,11890,0,0,0,0
+339,108791,108003,0,11996,0,0,0,0
+342,111667,114202,0,12102,0,0,0,0
+345,110875,111103,0,12208,0,0,0,0
+348,115334,114917,0,12314,0,0,0,0
+351,113000,112771,0,12420,0,0,0,0
+354,113459,113964,0,12527,0,0,0,0
+357,116167,115871,0,12633,0,0,0,0
+360,115709,115871,0,12739,0,0,0,0
+363,118166,118732,0,12845,0,0,0,0
+366,126750,127077,0,12951,0,0,0,0
+369,128583,128984,0,13057,0,0,0,0
+372,129458,128984,0,13163,0,0,0,0
+375,125709,125885,0,13269,0,0,0,0
+378,134417,134944,0,13376,0,0,0,0
+381,126250,126123,0,13482,0,0,0,0
+384,133875,134229,0,13588,0,0,0,0
+387,128583,128030,0,13694,0,0,0,0
+390,129291,132322,0,13800,0,0,0,0
+393,135000,135183,0,13906,0,0,0,0
+396,131667,130891,0,14012,0,0,0,0
+399,138333,138998,0,14118,0,0,0,0
+402,133041,133037,0,14225,0,0,0,0
+406,137375,138044,0,14366,0,0,0,0
+410,135875,135898,0,14508,0,0,0,0
+414,142917,143051,0,14649,0,0,0,0
+418,139750,140190,0,14791,0,0,0,0
+422,145167,146150,0,14932,0,0,0,0
+426,142625,141859,0,15074,0,0,0,0
+430,170125,169992,0,15215,0,0,0,0
+434,155125,154972,0,15357,0,0,0,0
+438,160083,159978,0,15498,0,0,0,0
+442,175625,174760,0,15640,0,0,0,0
+446,156250,157117,0,15781,0,0,0,0
+450,158750,159025,0,15923,0,0,0,0
+454,166542,166893,0,16064,0,0,0,0
+458,159666,159978,0,16206,0,0,0,0
+462,164209,163793,0,16347,0,0,0,0
+466,172375,172853,0,16489,0,0,0,0
+470,155917,155925,0,16630,0,0,0,0
+474,161041,161170,0,16772,0,0,0,0
+478,168041,167846,0,16913,0,0,0,0
+482,163834,164270,0,17055,0,0,0,0
+486,166541,165939,0,17196,0,0,0,0
+490,165625,165939,0,17338,0,0,0,0
+494,168916,169038,0,17479,0,0,0,0
+498,165583,164985,0,17621,0,0,0,0
+502,172042,171899,0,17762,0,0,0,0
+507,174459,174999,0,17939,0,0,0,0
+512,171250,171899,0,18116,0,0,0,0
+517,173750,174045,0,18293,0,0,0,0
+522,176417,176191,0,18470,0,0,0,0
+527,179625,179052,0,18646,0,0,0,0
+532,180541,180959,0,18823,0,0,0,0
+537,183541,182628,0,19000,0,0,0,0
+542,179583,179290,0,19177,0,0,0,0
+547,184458,184059,0,19354,0,0,0,0
+552,185709,185966,0,19531,0,0,0,0
+557,211667,211954,0,19708,0,0,0,0
+562,199625,200033,0,19885,0,0,0,0
+567,200541,199794,0,20061,0,0,0,0
+572,216916,217199,0,20238,0,0,0,0
+577,192625,193119,0,20415,0,0,0,0
+582,198625,199079,0,20592,0,0,0,0
+587,194000,194072,0,20769,0,0,0,0
+592,197375,196695,0,20946,0,0,0,0
+597,198084,197887,0,21123,0,0,0,0
+602,202333,202178,0,21300,0,0,0,0
+608,210958,210762,0,21512,0,0,0,0
+614,204209,203847,0,21724,0,0,0,0
+620,213458,214099,0,21936,0,0,0,0
+626,207791,206947,0,22149,0,0,0,0
+632,208959,209331,0,22361,0,0,0,0
+638,214000,214099,0,22573,0,0,0,0
+644,215500,216007,0,22785,0,0,0,0
+650,211000,211238,0,22998,0,0,0,0
+656,241625,241994,0,23210,0,0,0,0
+662,225875,226020,0,23422,0,0,0,0
+668,226375,226974,0,23634,0,0,0,0
+674,221459,221967,0,23847,0,0,0,0
+680,220250,220060,0,24059,0,0,0,0
+686,224375,224113,0,24271,0,0,0,0
+692,229666,228881,0,24483,0,0,0,0
+698,230041,230312,0,24696,0,0,0,0
+704,232250,231981,0,24908,0,0,0,0
+711,234875,235080,0,25155,0,0,0,0
+718,235500,236034,0,25403,0,0,0,0
+725,240584,240802,0,25651,0,0,0,0
+732,243667,243186,0,25898,0,0,0,0
+739,247708,247955,0,26146,0,0,0,0
+746,252875,252962,0,26394,0,0,0,0
+753,254709,254869,0,26641,0,0,0,0
+760,254500,254154,0,26889,0,0,0,0
+767,256209,256061,0,27136,0,0,0,0
+774,251125,250816,0,27384,0,0,0,0
+781,256917,257015,0,27632,0,0,0,0
+788,260375,260829,0,27879,0,0,0,0
+795,260417,260829,0,28127,0,0,0,0
+802,262917,262975,0,28375,0,0,0,0
+810,270375,271081,0,28658,0,0,0,0
+818,282583,282764,0,28941,0,0,0,0
+826,276958,277042,0,29224,0,0,0,0
+834,282125,282287,0,29507,0,0,0,0
+842,281833,282287,0,29790,0,0,0,0
+850,284209,283718,0,30073,0,0,0,0
+858,293333,293731,0,30356,0,0,0,0
+866,289666,290155,0,30639,0,0,0,0
+874,400833,400781,0,30922,0,0,0,0
+882,297000,300645,0,31205,0,0,0,0
+890,343000,343084,0,31488,0,0,0,0
+898,301500,301122,0,31771,0,0,0,0
+906,303958,303983,0,32054,0,0,0,0
+28,9375,10251,0,994,0,0,0,0
diff --git a/dune b/dune
index f66f84b33..feaaf0279 100644
--- a/dune
+++ b/dune
@@ -1,4 +1,4 @@
-(dirs packages demo doc)
+(dirs packages demo doc bench)
(documentation
(package server-reason-react))