Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add colored blockquotes! (Markdown preprocessor) + Benchmarks #484

Closed
Tracked by #308
caendesilva opened this issue Jun 1, 2022 · 3 comments
Closed
Tracked by #308

Add colored blockquotes! (Markdown preprocessor) + Benchmarks #484

caendesilva opened this issue Jun 1, 2022 · 3 comments

Comments

@caendesilva
Copy link
Member

caendesilva commented Jun 1, 2022

See #483 (comment)

@caendesilva caendesilva changed the title Colored blockquotes! (Easy to add with attributes extension) Add colored blockquotes! (Markdown preprocessor) Jun 1, 2022
@caendesilva
Copy link
Member Author

The system I'm working on now is pretty cool, but adds a lot of complexity. We'll see how it goes, maybe it belongs in a dedicated package. (crosspost from #483 (comment))

@caendesilva
Copy link
Member Author

image

@caendesilva
Copy link
Member Author

caendesilva commented Jun 1, 2022

Benchmarks for the feature as it is now:

Note this is a rather crude benchmark, rand() is used to try to spoof PHP from caching the results.

System info for all tests

PHP version OS/Arch xdebug opcache
8.0.13 (cli) WINNT (64-bit) enabled ✅ disabled ❌

The test cases

1 Benchmark baseline for parsing normal blockquote

Benchmark::run(function () {
    echo (new \Hyde\Framework\Services\MarkdownConverterService('> '.rand(0, 1000)))->parse();
}, 10000, 'Baseline Test');

2 Benchmark baseline for parsing normal blockquote with the entire preprocessing system disabled

Benchmark::run(function () {
    echo (new \Hyde\Framework\Services\MarkdownConverterService('> '.rand(0, 1000)))->parse();
}, 10000, 'Baseline No-Processing');

3 Benchmark for the colored blockquote preprocessor

Benchmark::run(function () {
    echo (new \Hyde\Framework\Services\MarkdownConverterService('>info '.rand(0, 1000)))->parse();
}, 10000, 'Colored Blockquotes');

Results (single line tests)

Name Total iterations Total execution time Avg. iteration time Avg. iterations/sec Approx. Memory usage
1 Baseline Test 10 000 29847.73ms 2.98477252ms 0.34 14MB
2 Baseline No-Processing 10 000 26405.78ms 2.64057779ms 0.38 14MB
3 Colored Blockquotes 10 000 27512.21ms 2.75122061ms 0.36 14MB

Result analysis

It's expected that the second case without any processing is the fastest. What I did not expect is that the colored blockquotes are faster. I wonder if this is because my test somehow is misrepresenting, though it in a way makes sense as it is very possible that my Markdown parser is faster than the CommonMark one. Either way, in this test scenario the difference is negligible, though I want to test with a multiline dataset.

@caendesilva caendesilva changed the title Add colored blockquotes! (Markdown preprocessor) Add colored blockquotes! (Markdown preprocessor) + Benchmarks Jun 1, 2022
caendesilva pushed a commit that referenced this issue Sep 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant