Skip to content

Underscores around text gives performance problems - SourceForge Issue #2086757 #7

Open
@myabc

Description

@myabc

From alex.coles on October 28, 2008 01:22:45

Underscores around text gives performance problems

I have discovered what appears to be a bug that can lead to rather severe
performance problems. The bug becomes evident when trying to "markdown"
strings similar to "_ _ _ _ _ _ text _ _ _ _ ". The easiest test case that
demonstrates this bug is the following code snippet: processor.markdown("

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ T");

After some testing, it seems like every additional "_ " BEFORE the "T" will
increase the time for "markdown" to execute doubles. When having 26 "_ "
(that is, underscore followed by space), the "markdown" takes about 100
seconds on my laptop. 25 "_ " takes around 50 seconds, and so on.

Below is the code snippet that can be used to reproduce the results.

If more details are needed, I can be contacted at Per Hallström
[email protected].

=== CODE ===
public void test2() {
String problematicPlaintext = "T";

for(int i=0;i<30;i++) {
long start = System.currentTimeMillis();
processor.markdown(problematicPlaintext);
long end = System.currentTimeMillis();
System.out.printf("i = %02d: %08d ms -- %56s\n", i,
(end-start), problematicPlaintext);
problematicPlaintext = "_ " + problematicPlaintext;
}
}

=== EXAMPLE OUTPUT ===

i = 15: 00000051 ms -- _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
T
i = 16: 00000096 ms -- _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
T
i = 17: 00000207 ms -- _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
T
i = 18: 00000405 ms -- _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
T
i = 19: 00000905 ms -- _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
T
i = 20: 00001514 ms -- _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
T
i = 21: 00003008 ms -- _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
T
i = 22: 00006115 ms -- _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
T
i = 23: 00012232 ms -- _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
T
i = 24: 00024220 ms -- _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
T
i = 25: 00048662 ms -- _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
T

Original issue: http://code.google.com/p/markdownj/issues/detail?id=4

Metadata

Metadata

Assignees

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions