benchmarks/markdown: add benches for markdown2
authorAlexandre Terrasa <alexandre@moz-code.org>
Wed, 20 Jun 2018 15:15:15 +0000 (11:15 -0400)
committerAlexandre Terrasa <alexandre@moz-code.org>
Thu, 21 Jun 2018 00:58:45 +0000 (20:58 -0400)
Signed-off-by: Alexandre Terrasa <alexandre@moz-code.org>

benchmarks/markdown/bench_markdown.sh
benchmarks/markdown/engines/Makefile
benchmarks/markdown/engines/nitmd2/Makefile [new file with mode: 0644]
benchmarks/markdown/engines/nitmd2/nitmd2.nit [new file with mode: 0644]

index d6826e1..338ba14 100755 (executable)
@@ -97,6 +97,30 @@ function bench_nitmd-o()
 }
 bench_nitmd-o
 
+function bench_nitmd2()
+{
+       name="$FUNCNAME"
+       skip_test "$name" && return
+       prepare_res $outdir/nitmd2.dat "nitmd2" "nitmd2"
+       for file in $bncdir/*.md; do
+               bench=`basename $file .md`
+               bench_command "$bench" "" "$engdir/nitmd2/nitmd2" "$file" "$s"
+       done
+}
+bench_nitmd2
+
+function bench_nitmd2-o()
+{
+       name="$FUNCNAME"
+       skip_test "$name" && return
+       prepare_res $outdir/nitmd2-o.dat "nitmd2-o" "nitmd2-o"
+       for file in $bncdir/*.md; do
+               bench=`basename $file .md`
+               bench_command "$bench" "" "$engdir/nitmd2/nitmd2-o" "$file" "$s"
+       done
+}
+bench_nitmd2-o
+
 function bench_txtmark()
 {
        name="$FUNCNAME"
index 1eeda88..711d69f 100644 (file)
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-all: nitmd/nitmd txtmark/Txtmark.class markdown4j/Markdown4j.class
+all: nitmd/nitmd nitmd2/nitmd2 txtmark/Txtmark.class markdown4j/Markdown4j.class
 
 nitmd/nitmd:
        make -C nitmd
 
+nitmd2/nitmd2:
+       make -C nitmd2
+
 txtmark/Txtmark.class:
        make -C txtmark
 
@@ -30,6 +33,7 @@ pandoc/pandoc:
 
 clean:
        make -C nitmd clean
+       make -C nitmd2 clean
        make -C txtmark clean
        make -C markdown4j clean
        make -C pandoc clean
diff --git a/benchmarks/markdown/engines/nitmd2/Makefile b/benchmarks/markdown/engines/nitmd2/Makefile
new file mode 100644 (file)
index 0000000..526ca83
--- /dev/null
@@ -0,0 +1,32 @@
+# This file is part of NIT ( http://www.nitlanguage.org ).
+#
+# Copyright 2015 Alexandre Terrasa <alexandre@moz-code.org>
+#
+# 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.
+
+NITC=../../../../bin/nitc
+
+all: nitmd2 nitmd2-o
+
+nitmd2:
+       $(NITC) nitmd2.nit
+
+nitmd2-o:
+       $(NITC) --semi-global nitmd2.nit -o $@
+
+test: all
+       ./nitmd2 ../../benches/hello.md 5
+       ./nitmd2-o ../../benches/hello.md 5
+
+clean:
+       rm -rf nitmd2 nitmd2-o
diff --git a/benchmarks/markdown/engines/nitmd2/nitmd2.nit b/benchmarks/markdown/engines/nitmd2/nitmd2.nit
new file mode 100644 (file)
index 0000000..d705618
--- /dev/null
@@ -0,0 +1,26 @@
+# This file is part of NIT ( http://www.nitlanguage.org ).
+#
+# 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.
+
+import markdown2
+
+var file = args.first
+var n = args[1].to_i
+
+var str = file.to_path.read_all
+var parser = new MdParser
+var renderer = new HtmlRenderer
+for i in [1..n] do
+       var doc = parser.parse(str)
+       print renderer.render(doc)
+end