-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
88 changed files
with
549 additions
and
642 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
web: node support/babelmark-responder.js | ||
web: node support/babelmark-responder.mjs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,110 @@ | ||
#!/usr/bin/env node | ||
/*eslint no-console:0*/ | ||
|
||
import { createRequire } from 'node:module'; | ||
const require = createRequire(import.meta.url); | ||
|
||
var fs = require('fs'); | ||
var util = require('util'); | ||
var Benchmark = require('benchmark'); | ||
var ansi = require('ansi'); | ||
var cursor = ansi(process.stdout); | ||
|
||
var IMPLS = []; | ||
|
||
for (const name of fs.readdirSync(new URL('./implementations', import.meta.url)).sort()) { | ||
const filepath = new URL(`./implementations/${name}/index.mjs`, import.meta.url); | ||
const code = (await import(filepath)); | ||
|
||
IMPLS.push({ | ||
name: name, | ||
code: code | ||
}); | ||
} | ||
|
||
const SAMPLES = []; | ||
|
||
fs.readdirSync(new URL('./samples', import.meta.url)).sort().forEach(sample => { | ||
const filepath = new URL(`./samples/${sample}`, import.meta.url); | ||
|
||
const content = {}; | ||
|
||
content.string = fs.readFileSync(filepath, 'utf8'); | ||
|
||
var title = `(${content.string.length} bytes)`; | ||
|
||
function onComplete() { cursor.write('\n'); } | ||
|
||
var suite = new Benchmark.Suite( | ||
title, | ||
{ | ||
onStart: () => { console.log('\nSample: %s %s', sample, title); }, | ||
onComplete: onComplete | ||
} | ||
); | ||
|
||
IMPLS.forEach(function (impl) { | ||
suite.add( | ||
impl.name, | ||
{ | ||
onCycle: function onCycle(event) { | ||
cursor.horizontalAbsolute(); | ||
cursor.eraseLine(); | ||
cursor.write(' > ' + event.target); | ||
}, | ||
onComplete: onComplete, | ||
fn: function () { impl.code.run(content.string); } | ||
} | ||
); | ||
}); | ||
|
||
SAMPLES.push({ | ||
name: sample.split('.')[0], | ||
title: title, | ||
content: content, | ||
suite: suite | ||
}); | ||
}); | ||
|
||
|
||
function select(patterns) { | ||
var result = []; | ||
|
||
if (!(patterns instanceof Array)) { | ||
patterns = [ patterns ]; | ||
} | ||
|
||
function checkName(name) { | ||
return patterns.length === 0 || patterns.some(function (regexp) { | ||
return regexp.test(name); | ||
}); | ||
} | ||
|
||
SAMPLES.forEach(function (sample) { | ||
if (checkName(sample.name)) { | ||
result.push(sample); | ||
} | ||
}); | ||
|
||
return result; | ||
} | ||
|
||
|
||
function run(files) { | ||
var selected = select(files); | ||
|
||
if (selected.length > 0) { | ||
console.log('Selected samples: (%d of %d)', selected.length, SAMPLES.length); | ||
selected.forEach(function (sample) { | ||
console.log(' > %s', sample.name); | ||
}); | ||
} else { | ||
console.log('There isn\'t any sample matches any of these patterns: %s', util.inspect(files)); | ||
} | ||
|
||
selected.forEach(function (sample) { | ||
sample.suite.run(); | ||
}); | ||
} | ||
|
||
run(process.argv.slice(2).map(source => new RegExp(source, 'i'))); |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { createRequire } from 'node:module'; | ||
const require = createRequire(import.meta.url); | ||
|
||
const commonmark = require('../../extra/lib/node_modules/commonmark'); | ||
|
||
var parser = new commonmark.Parser(); | ||
var renderer = new commonmark.HtmlRenderer(); | ||
|
||
export function run(data) { | ||
return renderer.render(parser.parse(data)); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import markdownit from '../../../index.mjs'; | ||
|
||
var md = markdownit({ | ||
html: true, | ||
linkify: true, | ||
typographer: true | ||
}); | ||
|
||
export function run(data) { | ||
return md.render(data); | ||
} |
7 changes: 0 additions & 7 deletions
7
benchmark/implementations/markdown-it-2.2.1-commonmark/index.js
This file was deleted.
Oops, something went wrong.
10 changes: 10 additions & 0 deletions
10
benchmark/implementations/markdown-it-2.2.1-commonmark/index.mjs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import { createRequire } from 'node:module'; | ||
const require = createRequire(import.meta.url); | ||
|
||
const markdownit = require('../../extra/lib/node_modules/markdown-it'); | ||
|
||
var md = markdownit('commonmark'); | ||
|
||
export function run(data) { | ||
return md.render(data); | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import { createRequire } from 'node:module'; | ||
const require = createRequire(import.meta.url); | ||
|
||
const marked = require('../../extra/lib/node_modules/marked'); | ||
|
||
export function run(data) { | ||
return marked(data); | ||
} |
Oops, something went wrong.