@@ -88,18 +88,23 @@ func TestAutogeneratedIDs(t *testing.T) {
88
88
}
89
89
}
90
90
91
+ func nowMillis () int64 {
92
+ // TODO: replace UnixNano to UnixMillis(drops Go1.16 support)
93
+ return time .Now ().UnixNano () / 1000000
94
+ }
95
+
91
96
func TestDeepNestedLabelPerformance (t * testing.T ) {
92
97
markdown := New (WithRendererOptions (
93
98
html .WithXHTML (),
94
99
html .WithUnsafe (),
95
100
))
96
101
97
- started := time . Now (). UnixMilli ()
102
+ started := nowMillis ()
98
103
n := 50000
99
104
source := []byte (strings .Repeat ("[" , n ) + strings .Repeat ("]" , n ))
100
105
var b bytes.Buffer
101
106
_ = markdown .Convert (source , & b )
102
- finished := time . Now (). UnixMilli ()
107
+ finished := nowMillis ()
103
108
if (finished - started ) > 5000 {
104
109
t .Error ("Parsing deep nested labels took more 5 secs" )
105
110
}
@@ -111,12 +116,12 @@ func TestManyProcessingInstructionPerformance(t *testing.T) {
111
116
html .WithUnsafe (),
112
117
))
113
118
114
- started := time . Now (). UnixMilli ()
119
+ started := nowMillis ()
115
120
n := 50000
116
121
source := []byte ("a " + strings .Repeat ("<?" , n ))
117
122
var b bytes.Buffer
118
123
_ = markdown .Convert (source , & b )
119
- finished := time . Now (). UnixMilli ()
124
+ finished := nowMillis ()
120
125
if (finished - started ) > 5000 {
121
126
t .Error ("Parsing processing instructions took more 5 secs" )
122
127
}
@@ -128,12 +133,12 @@ func TestManyCDATAPerformance(t *testing.T) {
128
133
html .WithUnsafe (),
129
134
))
130
135
131
- started := time . Now (). UnixMilli ()
136
+ started := nowMillis ()
132
137
n := 50000
133
138
source := []byte (strings .Repeat ("a <![CDATA[" , n ))
134
139
var b bytes.Buffer
135
140
_ = markdown .Convert (source , & b )
136
- finished := time . Now (). UnixMilli ()
141
+ finished := nowMillis ()
137
142
if (finished - started ) > 5000 {
138
143
t .Error ("Parsing processing instructions took more 5 secs" )
139
144
}
@@ -145,12 +150,12 @@ func TestManyDeclPerformance(t *testing.T) {
145
150
html .WithUnsafe (),
146
151
))
147
152
148
- started := time . Now (). UnixMilli ()
153
+ started := nowMillis ()
149
154
n := 50000
150
155
source := []byte (strings .Repeat ("a <!A " , n ))
151
156
var b bytes.Buffer
152
157
_ = markdown .Convert (source , & b )
153
- finished := time . Now (). UnixMilli ()
158
+ finished := nowMillis ()
154
159
if (finished - started ) > 5000 {
155
160
t .Error ("Parsing processing instructions took more 5 secs" )
156
161
}
@@ -162,12 +167,12 @@ func TestManyCommentPerformance(t *testing.T) {
162
167
html .WithUnsafe (),
163
168
))
164
169
165
- started := time . Now (). UnixMilli ()
170
+ started := nowMillis ()
166
171
n := 50000
167
172
source := []byte (strings .Repeat ("a <!-- " , n ))
168
173
var b bytes.Buffer
169
174
_ = markdown .Convert (source , & b )
170
- finished := time . Now (). UnixMilli ()
175
+ finished := nowMillis ()
171
176
if (finished - started ) > 5000 {
172
177
t .Error ("Parsing processing instructions took more 5 secs" )
173
178
}
0 commit comments