@@ -97,17 +97,17 @@ public static void PopulateTestData()
9797 /// <summary>
9898 /// Render a templates
9999 /// </summary>
100- /// <param name="createJsEngine">Delegate for create an instance of the JS engine</param>
101- /// <param name="withPrecompilation ">Flag for whether to allow execution of JS code with pre-compilation</param>
102- private static void RenderTemplates ( Func < IJsEngine > createJsEngine , bool withPrecompilation )
100+ /// <param name="jsEngineFactory"> JS engine factory </param>
101+ /// <param name="precompileScript ">Flag for whether to allow execution of JS code with pre-compilation</param>
102+ private static void RenderTemplates ( IJsEngineFactory jsEngineFactory , bool precompileScript )
103103 {
104104 // Arrange
105105 IPrecompiledScript precompiledCode = null ;
106106
107107 // Act
108- using ( var jsEngine = createJsEngine ( ) )
108+ using ( var jsEngine = jsEngineFactory . CreateEngine ( ) )
109109 {
110- if ( withPrecompilation )
110+ if ( precompileScript )
111111 {
112112 if ( ! jsEngine . SupportsScriptPrecompilation )
113113 {
@@ -128,9 +128,9 @@ private static void RenderTemplates(Func<IJsEngine> createJsEngine, bool withPre
128128
129129 for ( int itemIndex = 1 ; itemIndex < _contentItems . Length ; itemIndex ++ )
130130 {
131- using ( var jsEngine = createJsEngine ( ) )
131+ using ( var jsEngine = jsEngineFactory . CreateEngine ( ) )
132132 {
133- if ( withPrecompilation )
133+ if ( precompileScript )
134134 {
135135 jsEngine . Execute ( precompiledCode ) ;
136136 }
@@ -153,111 +153,116 @@ private static void RenderTemplates(Func<IJsEngine> createJsEngine, bool withPre
153153 [ Benchmark ]
154154 [ Arguments ( false ) ]
155155 [ Arguments ( true ) ]
156- public void ChakraCore ( bool withPrecompilation )
156+ public void ChakraCore ( bool precompileScript )
157157 {
158- Func < IJsEngine > createJsEngine = ( ) => new ChakraCoreJsEngine ( ) ;
159- RenderTemplates ( createJsEngine , withPrecompilation ) ;
158+ IJsEngineFactory jsEngineFactory = new ChakraCoreJsEngineFactory ( ) ;
159+ RenderTemplates ( jsEngineFactory , precompileScript ) ;
160160 }
161161
162162 [ Benchmark ]
163- [ Arguments ( false ) ]
164- [ Arguments ( true ) ]
165- public void Jint ( bool withPrecompilation )
163+ [ Arguments ( false , false ) ]
164+ [ Arguments ( true , false ) ]
165+ [ Arguments ( true , true ) ]
166+ public void Jint ( bool precompileScript , bool compileRegex )
166167 {
167- Func < IJsEngine > createJsEngine = ( ) => new JintJsEngine ( ) ;
168- RenderTemplates ( createJsEngine , withPrecompilation ) ;
168+ IJsEngineFactory jsEngineFactory = new JintJsEngineFactory ( new JintSettings
169+ {
170+ CompileRegex = compileRegex
171+ } ) ;
172+ RenderTemplates ( jsEngineFactory , precompileScript ) ;
169173 }
170174
171175 [ Benchmark ]
172176 [ Arguments ( false ) ]
173177 [ Arguments ( true ) ]
174- public void Jurassic ( bool withPrecompilation )
178+ public void Jurassic ( bool precompileScript )
175179 {
176- Func < IJsEngine > createJsEngine = ( ) => new JurassicJsEngine ( ) ;
177- RenderTemplates ( createJsEngine , withPrecompilation ) ;
180+ IJsEngineFactory jsEngineFactory = new JurassicJsEngineFactory ( ) ;
181+ RenderTemplates ( jsEngineFactory , precompileScript ) ;
178182 }
179183#if NET462
180184
181185 [ Benchmark ]
182186 public void MsieClassic ( )
183187 {
184- Func < IJsEngine > createJsEngine = ( ) => new MsieJsEngine ( new MsieSettings
188+ IJsEngineFactory jsEngineFactory = new MsieJsEngineFactory ( new MsieSettings
185189 {
186190 EngineMode = JsEngineMode . Classic ,
191+ UseEcmaScript5Polyfill = true ,
187192 UseJson2Library = true
188193 } ) ;
189- RenderTemplates ( createJsEngine , false ) ;
194+ RenderTemplates ( jsEngineFactory , false ) ;
190195 }
191196
192197 [ Benchmark ]
193198 public void MsieChakraActiveScript ( )
194199 {
195- Func < IJsEngine > createJsEngine = ( ) => new MsieJsEngine ( new MsieSettings
200+ IJsEngineFactory jsEngineFactory = new MsieJsEngineFactory ( new MsieSettings
196201 {
197202 EngineMode = JsEngineMode . ChakraActiveScript
198203 } ) ;
199- RenderTemplates ( createJsEngine , false ) ;
204+ RenderTemplates ( jsEngineFactory , false ) ;
200205 }
201206#endif
202207 [ Benchmark ]
203208 [ Arguments ( false ) ]
204209 [ Arguments ( true ) ]
205- public void MsieChakraIeJsRt ( bool withPrecompilation )
210+ public void MsieChakraIeJsRt ( bool precompileScript )
206211 {
207- Func < IJsEngine > createJsEngine = ( ) => new MsieJsEngine ( new MsieSettings
212+ IJsEngineFactory jsEngineFactory = new MsieJsEngineFactory ( new MsieSettings
208213 {
209214 EngineMode = JsEngineMode . ChakraIeJsRt
210215 } ) ;
211- RenderTemplates ( createJsEngine , withPrecompilation ) ;
216+ RenderTemplates ( jsEngineFactory , precompileScript ) ;
212217 }
213218
214219 [ Benchmark ]
215220 [ Arguments ( false ) ]
216221 [ Arguments ( true ) ]
217- public void MsieChakraEdgeJsRt ( bool withPrecompilation )
222+ public void MsieChakraEdgeJsRt ( bool precompileScript )
218223 {
219- Func < IJsEngine > createJsEngine = ( ) => new MsieJsEngine ( new MsieSettings
224+ IJsEngineFactory jsEngineFactory = new MsieJsEngineFactory ( new MsieSettings
220225 {
221226 EngineMode = JsEngineMode . ChakraEdgeJsRt
222227 } ) ;
223- RenderTemplates ( createJsEngine , withPrecompilation ) ;
228+ RenderTemplates ( jsEngineFactory , precompileScript ) ;
224229 }
225230
226231 [ Benchmark ]
227232 public void NiL ( )
228233 {
229- Func < IJsEngine > createJsEngine = ( ) => new NiLJsEngine ( ) ;
230- RenderTemplates ( createJsEngine , false ) ;
234+ IJsEngineFactory jsEngineFactory = new NiLJsEngineFactory ( ) ;
235+ RenderTemplates ( jsEngineFactory , false ) ;
231236 }
232237
233238 [ Benchmark ]
234239 public void Node ( )
235240 {
236- Func < IJsEngine > createJsEngine = ( ) => new NodeJsEngine ( ) ;
237- RenderTemplates ( createJsEngine , false ) ;
241+ IJsEngineFactory jsEngineFactory = new NodeJsEngineFactory ( ) ;
242+ RenderTemplates ( jsEngineFactory , false ) ;
238243 }
239244
240245 [ Benchmark ]
241246 [ Arguments ( false ) ]
242247 [ Arguments ( true ) ]
243- public void V8 ( bool withPrecompilation )
248+ public void V8 ( bool precompileScript )
244249 {
245- Func < IJsEngine > createJsEngine = ( ) => new V8JsEngine ( ) ;
246- RenderTemplates ( createJsEngine , withPrecompilation ) ;
250+ IJsEngineFactory jsEngineFactory = new V8JsEngineFactory ( ) ;
251+ RenderTemplates ( jsEngineFactory , precompileScript ) ;
247252 }
248253
249254 [ Benchmark ]
250255 public void Vroom ( )
251256 {
252- Func < IJsEngine > createJsEngine = ( ) => new VroomJsEngine ( ) ;
253- RenderTemplates ( createJsEngine , false ) ;
257+ IJsEngineFactory jsEngineFactory = new VroomJsEngineFactory ( ) ;
258+ RenderTemplates ( jsEngineFactory , false ) ;
254259 }
255260
256261 [ Benchmark ]
257262 public void Yantra ( )
258263 {
259- Func < IJsEngine > createJsEngine = ( ) => new YantraJsEngine ( ) ;
260- RenderTemplates ( createJsEngine , false ) ;
264+ IJsEngineFactory jsEngineFactory = new YantraJsEngineFactory ( ) ;
265+ RenderTemplates ( jsEngineFactory , false ) ;
261266 }
262267
263268 #region Internal types
0 commit comments