问题描述
我之前在没有基于模板的基准测试的情况下成功使用了基准测试,但是基于模板的基准测试在这里不能工作。 我使用 https://docs.optaplanner.org/
中的测试用例<plannerBenchmark>
<benchmarkDirectory>local/data</benchmarkDirectory>
<parallelBenchmarkCount>(availableProcessorCount / 2)+1</parallelBenchmarkCount>
<warmUpSecondsspentLimit>60</warmUpSecondsspentLimit>
<inheritedSolverBenchmark>
...
</inheritedSolverBenchmark>
<#list [5,7,11,13] as entityTabuSize>
<#list [500,1000,2000] as acceptedCountLimit>
<solverBenchmark>
<name>Tabu Search entityTabuSize ${entityTabuSize} acceptedCountLimit ${acceptedCountLimit}</name>
<solver>
<localSearch>
<unionMoveSelector>
<changeMoveSelector/>
<swapMoveSelector/>
</unionMoveSelector>
<acceptor>
<entityTabuSize>${entityTabuSize}</entityTabuSize>
</acceptor>
<forager>
<acceptedCountLimit>${acceptedCountLimit}</acceptedCountLimit>
</forager>
</localSearch>
</solver>
</solverBenchmark>
</#list>
</#list>
</plannerBenchmark>
好像有问题
<#list [5,13] as entityTabuSize>
optaPlanner 版本是 7.43.0 xstream 版本为 1.4.14
有sonme错误信息
Caused by: com.thoughtworks.xstream.converters.ConversionException:
---- Debugging information ----
cause-exception : com.thoughtworks.xstream.io.StreamException
cause-message :
class : org.optaplanner.benchmark.config.PlannerBenchmarkConfig
required-type : org.optaplanner.benchmark.config.PlannerBenchmarkConfig
converter-type : com.thoughtworks.xstream.converters.reflection.ReflectionConverter
line number : 40
version : 1.4.14
-------------------------------
at com.thoughtworks.xstream.core.TreeUnmarshaller.convert(TreeUnmarshaller.java:77)
at com.thoughtworks.xstream.core.AbstractReferenceUnmarshaller.convert(AbstractReferenceUnmarshaller.java:72)
at com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:66)
at com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:50)
at com.thoughtworks.xstream.core.TreeUnmarshaller.start(TreeUnmarshaller.java:134)
at com.thoughtworks.xstream.core.AbstractTreeMarshallingStrategy.unmarshal(AbstractTreeMarshallingStrategy.java:32)
at com.thoughtworks.xstream.XStream.unmarshal(XStream.java:1404)
at com.thoughtworks.xstream.XStream.unmarshal(XStream.java:1383)
at com.thoughtworks.xstream.XStream.fromXML(XStream.java:1268)
at org.optaplanner.benchmark.config.PlannerBenchmarkConfig.createFromXmlReader(PlannerBenchmarkConfig.java:228)
at org.optaplanner.benchmark.config.PlannerBenchmarkConfig.createFromXmlInputStream(PlannerBenchmarkConfig.java:204)
at org.optaplanner.benchmark.config.PlannerBenchmarkConfig.createFromXmlResource(PlannerBenchmarkConfig.java:140)
... 21 more
Caused by: com.thoughtworks.xstream.io.StreamException:
at com.thoughtworks.xstream.io.xml.XppReader.pullNextEvent(XppReader.java:124)
at com.thoughtworks.xstream.io.xml.AbstractPullReader.readRealEvent(AbstractPullReader.java:148)
at com.thoughtworks.xstream.io.xml.AbstractPullReader.readEvent(AbstractPullReader.java:135)
at com.thoughtworks.xstream.io.xml.AbstractPullReader.hasMoreChildren(AbstractPullReader.java:87)
at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.doUnmarshal(AbstractReflectionConverter.java:329)
at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.unmarshal(AbstractReflectionConverter.java:277)
at com.thoughtworks.xstream.core.TreeUnmarshaller.convert(TreeUnmarshaller.java:72)
... 32 more
Caused by: org.xmlpull.v1.XmlPullParserException: unexpected character in markup # (position: END_TAG seen ...</inheritedSolverBenchmark>\r\n\r\n\r\n<#... @40:3)
at org.xmlpull.mxp1.MXParser.nextImpl(MXParser.java:1261)
at org.xmlpull.mxp1.MXParser.next(MXParser.java:1093)
at com.thoughtworks.xstream.io.xml.XppReader.pullNextEvent(XppReader.java:109)
... 38 more
解决方法
根据stacktrace,您使用的是PlannerBenchmarkConfig.createFromXmlResource()
,可用于读取基准配置XML,但不能读取FreeMarker 模板。
要读取基准配置 FreeMarker 模板,请使用 PlannerBenchmarkConfig.createFromFreemarkerXmlResource()
方法之一。
有关详情,请参阅 Template-based benchmarking。