【发布时间】:2016-01-12 13:08:07
【问题描述】:
【问题讨论】:
-
您可以像使用任何其他 js 库一样使用 purescript 输出。您能否告诉我们您尝试过的内容并提供您想要进行基准测试的脚本。即使我没有使用它的经验 - 看看 'purescript-benchotron'
标签: purescript jsperf
【问题讨论】:
标签: purescript jsperf
因为您指的是 JavaScript 实用程序,所以用 JS 编写测试是最容易的。
您可以在单独的 js 文件中编写性能测试(根据您的测试模块名称命名),并通过 Foreign Function Interface 从 purescript 调用它。
假设你想比较f和g函数的性能,代码方案可以用以下模板描述:
-- File PerfTest.purs
module PerfTest where
f :: Args -> Result
f args = ...
g :: Args -> Result
g args = ...
foreign import performanceTestImpl
:: forall a. (Unit -> a) -> (Unit -> a) -> Unit
main :: Effect Unit
main =
pure $ performanceTestImpl (\_ -> f args) (\_ -> g args)
// File PerfTest.js
"use static";
exports.performanceTestImpl =
function(runF) {
return function(runG) {
// run jsPerf tests as you would normally do
};
};
这会将performanceTestImpl 实现委托给带有两个回调的JavaScript,它们的性能应该被测量和比较。请注意,您需要传递未计算的 lambda 以延迟计算,因为 PureScript 不像 Haskell 那样惰性。 PureScript 应该负责链接。请注意,这两个文件需要具有匹配的名称并放在同一目录中。
【讨论】: