我写了一组验收测试,并试图用它们来测试库的性能.不幸的是,我似乎只能选择一个单独的测试和"创建性能会话"......这并没有给出整个应用程序性能的真实情况.
有没有办法一次性获得所有测试的性能报告?
我正在使用此扩展方法使用xslt转换非常大的xml文件.
不幸的是,我在source.ToString()行上得到了一个OutOfMemoryException.
我意识到必须有一个更好的方法,我只是不确定那会是什么?
public static XElement Transform(this XElement source, string xslPath, XsltArgumentList arguments)
{
var doc = new XmlDocument();
doc.LoadXml(source.ToString());
var xsl = new XslCompiledTransform();
xsl.Load(xslPath);
using (var swDocument = new StringWriter(System.Globalization.CultureInfo.InvariantCulture))
{
using (var xtw = new XmlTextWriter(swDocument))
{
xsl.Transform((doc.CreateNavigator()), arguments, xtw);
xtw.Flush();
return XElement.Parse(swDocument.ToString());
}
}
}
Run Code Online (Sandbox Code Playgroud)
思考?解决方案?等等.
更新:现在这已经解决了,我在验证架构时遇到了问题! 验证大型Xml文件
我有以下实现,但我想添加一个阈值,所以如果结果将大于它,只需停止计算并返回.
我该怎么办呢?
编辑:这是我目前的代码,threshold尚未使用...目标是它被使用
public static int DamerauLevenshteinDistance(string string1, string string2, int threshold)
{
// Return trivial case - where they are equal
if (string1.Equals(string2))
return 0;
// Return trivial case - where one is empty
if (String.IsNullOrEmpty(string1) || String.IsNullOrEmpty(string2))
return (string1 ?? "").Length + (string2 ?? "").Length;
// Ensure string2 (inner cycle) is longer
if (string1.Length > string2.Length)
{
var tmp = string1;
string1 = string2;
string2 = tmp;
}
// Return trivial case - where string1 is …Run Code Online (Sandbox Code Playgroud) 转换小时似乎需要做很多工作......必须有一个更简单的方法.
<xsl:variable name="hour12">
<xsl:choose>
<xsl:when test="$hour24 < 0">
<xsl:value-of select="12 + $hour24" />
</xsl:when>
<xsl:when test="$hour24 = 0">
<xsl:value-of select="12" />
</xsl:when>
<xsl:when test="$hour24 = 12">
<xsl:value-of select="$hour24" />
</xsl:when>
<xsl:when test="$hour24 > 12">
<xsl:value-of select="$hour24 - 12" />
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$hour24" />
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
Run Code Online (Sandbox Code Playgroud)
有什么建议?
我们有两个项目,kotlin 项目发布了一个由 java 导入的包。
在 kotlin 中,是一个像这样的值类
@JvmInline
value class CountryId(private val id: UUID) {
override fun toString(): String = id.toString()
companion object { fun empty(): CountryId = CountryId(EMPTY_UUID) }
}
Run Code Online (Sandbox Code Playgroud)
在java中,我们看不到构造函数,也看不到实际实例化这个类。我还尝试在 Kotlin 中创建一个工厂来创建它们
class IdentifierFactory
{
companion object {
fun buildString(): String {
return "hello"
}
fun buildCountry(): CountryId {
return CountryId.empty()
}
}
}
Run Code Online (Sandbox Code Playgroud)
在java中,我可以调用IdentifierFactory.Companion.buildString()它并且它会工作,但它IdentifierFactory.Companion.buildCountry()甚至不存在。
Java 的 Value 类真的这么糟糕吗?
附:我也尝试过@JvmStatic,但没有成功
pps。如果我从java端反编译kotlin字节码,并得到一个CountryId.decompiled.java,这就是构造函数的样子
// $FF: synthetic method
private CountryId(UUID id) {
Intrinsics.checkNotNullParameter(id, "id");
super();
this.id = …Run Code Online (Sandbox Code Playgroud) 我有以下正则表达式,在新情况出现之前完美运行
^.*[?&]U(?:RL)?=(?<URL>.*)$
Run Code Online (Sandbox Code Playgroud)
基本上,它用于对抗URL,在U =或URL =之后获取一切,并在URL匹配中返回它
所以,对于以下内容
HTTP://本地主机A = B&U = HTTP:// OTHERHOST富=酒吧
URL = http:// otherhost?foo = bar
不幸的是,出现了奇怪的情况
HTTP://本地主机A = B&U = HTTP:// OTHERHOST富=栏&URL = HTTP:// someotherhost
理想情况下,我希望URL为" http:// otherhost?foo = bar&url = http:// someotherhost ",相反,它只是" http:// someotherhost "
编辑:我认为这解决了它...虽然它不漂亮
^.*[?&](?<![?&]U(?:RL)?=.*)U(?:RL)?=(?<URL>.*)$
Run Code Online (Sandbox Code Playgroud) 我需要选择包含多个类的所有元素.类名无关紧要,我只需要选择两个或更多的元素.
这个jQuery选择器会是什么样的?
我正在继承一些代码,我有两个他们的测试仍然失败,不确定它们是不是以前的,或者是因为我有不同版本的 Jasmine(它们是 2.0 之前的)
失败的测试在 beforeEach 中有这个间谍设置
spyOn(datacontext, 'getImportLogForDate').and.callThrough();
Run Code Online (Sandbox Code Playgroud)
然后在测试中
controller.DepositDate = new Date();
controller.PerformActionThatCallsGetImportLogForDate();
expect(context.getImportLogForDate).toHaveBeenCalledWith('1', controller.DepositDate);
Run Code Online (Sandbox Code Playgroud)
由此产生的错误令人困惑,因为它们是相同的
预期 spy getImportLogForDate 已被调用['1', Date(Thu Dec 04 2014 13:00:51 GMT-0600 (Central Standard Time))]但实际调用是['1', Date(Thu Dec 04 2014 13) :00:51 GMT-0600(中部标准时间))]。
我不能验证使用日期调用的函数吗?
我最终尝试运行查询时收到以下错误
"IsFalse"类型的未知LINQ表达式
这是代码
private static IQueryable<T> QueryMethod<T>(
IQueryable<T> query,
QueryableRequestMessage.WhereClause.Rule rule,
Type type,
string methodName,
Expression property,
Expression value,
string op,
ParameterExpression parameter
) where T : class
{
var methodInfo = type.GetMethod(methodName, new[] { type });
var call = Expression.Call(property, methodInfo, value);
var expression = rule.Op.Equals(op)
? Expression.Lambda<Func<T, bool>>(call, parameter)
: Expression.Lambda<Func<T, bool>>(Expression.IsFalse(call), parameter);
query = query.Where(expression);
return query;
}
Run Code Online (Sandbox Code Playgroud)
重要变量具有以下值
query: an IQueryable that I am building up
type: String
methodName: "EndsWith"
rule.Op: "ne" //Not Ends With
op: …Run Code Online (Sandbox Code Playgroud) c# ×3
xslt ×2
jasmine ×1
java ×1
jquery ×1
kotlin ×1
linq ×1
performance ×1
photoshop ×1
regex ×1
regex-greedy ×1
testing ×1
threshold ×1
unit-testing ×1
value-class ×1
xml ×1