为什么 VSCode 中没有显示 Julia 基准测试?

发布于 2025-01-13 22:07:56 字数 576 浏览 2 评论 0原文

您好,下面是一些简单的代码,显示 Julia REPL 的基准测试结果。在 VSCode 中,我尝试

  1. 从命令托盘启动 Julia REPL 并在不调试的情况下运行文件
  2. 从右上角的下拉菜单中执行 Repl 中的活动文件

在这两种情况下,都会显示 println 语句,但不会显示基准测试结果。这是预料之中的还是我搞砸了?

using DifferentialEquations, BenchmarkTools
A = rand(1000,1000); B = rand(1000,1000); C = rand(1000,1000)
println("TX 1 and 2")
test(A,B,C) = A + B + C
@benchmark test(A,B,C)
println("T 1 End")

t(A,B,C) = A .+ B .+ C
@benchmark t(A,B,C)
println("TX 2 End")
readline()
println("After read")

我找到了一个解决方法:从文件中删除或注释掉@benchmark,然后 直接在 REPL 中运行它们。

Hi Below is some simple code that displays the benchmark results form a Julia REPL. In VSCode I have tried

  1. launching the Julia REPL from the Command Pallet and Running the file without Debugging
  2. Execute the active File in Repl from the drop down menu top right

In both cases the println statements are displayed but not the benchmark results. Is this to be expected or have I messed up?

using DifferentialEquations, BenchmarkTools
A = rand(1000,1000); B = rand(1000,1000); C = rand(1000,1000)
println("TX 1 and 2")
test(A,B,C) = A + B + C
@benchmark test(A,B,C)
println("T 1 End")

t(A,B,C) = A .+ B .+ C
@benchmark t(A,B,C)
println("TX 2 End")
readline()
println("After read")

I found a workaround : remove or comment out the @benchmark from the file and
run them directly in the REPL.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

听你说爱我 2025-01-20 22:07:56

这应该取决于结果类型的设置(Julia > Execution:设置 GUI 中的结果类型或 settings.json 中的 julia.execution.resultType )。

使用“内联”结果类型,我得到:

在此处输入图像描述

将鼠标悬停在 BenchmarkTools.Trial 框上,我得到:

在此处输入图像描述

请注意,println 行仅显示一个勾号,因为它已被执行,但没有返回任何内容,而是打印到 REPL,底部的终端现在如下所示:

<一href="https://i.sstatic.net/F1p9n.png" rel="nofollow noreferrer">在此处输入图像描述

This should depend on which setting you have for result type (Julia > Execution: Result Type in the Settings GUI or julia.execution.resultType in settings.json).

With "inline" result type I get:

enter image description here

Hovering over the BenchmarkTools.Trial box, I get:

enter image description here

Note the println line just shows a tick as it has been executed but didn't return anything, instead it printed to the REPL, the terminal at the bottom now looks like this:

enter image description here

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文