3

Unfortunately, I'm working on a website that uses XSL for everything. The performance is dire. Time spent in JIT is like 30%!

I always put the fact that this company needs 4 servers to run its little sites is down to the XSL, but I'm finally doing a proper perf review and although XSL is totally the culprit, I suspect that XSL isn't supposed to be this bad, that the original programmers (who were JavaScript guys) misused the XslCompiledTransform type.

Problem is, I'm no better able to use this API myself. The class was renewed for .NET 2.0 with compilation caching included. I have spent all day trying to work out under what circumstances caching works; originally the code newed-up an XslCompiledTransform for each transformation, which didn't seem right but making it static also doesn't help - performance profiling shows no improvement.

Further, in the debugger output pane, I can see Loaded 'System.Xml.Xsl.CompiledQuery.5' popping up for the same stylesheet, so it looks like its compiling, loading again each time.

It's suddenly occurred to me that maybe I'm supposed to do the caching, i.e. that I'm supposed to keep a store with one of these XslCompiledTransform instances for each stylesheet, preloaded or lazy-loaded.

Is this right?? Keeping one instance and calling Load many times for each stylesheet is incorrect?

4

2 回答 2

2

编译样式表通常比运行它需要更长的时间。您应该编译一次样式表,然后重用 CompiledStylesheet 对象来运行每个转换。

(感谢 John Nicholas 推荐使用 Saxon,我衷心赞同这一点,但它与这个问题并不真正相关,因为 Saxon API 很容易被滥用。)

于 2013-09-04T16:59:28.250 回答
0

作为 ac# dev id 建议为 xslt 走撒克逊人的路线。

http://saxon.sourceforge.net/

如果过时,则 xpath 的 ms 实现。它也不是那么快。

于 2013-09-04T16:35:22.470 回答