为什么CssProviderLeaf持续大约1600毫秒?
julia> using Gtk
julia> name ="FieldName"
"FieldName"
julia> @time Gtk.CssProviderLeaf(data="#$name {background:#C0C0C0;border-width:2px}")
3.397363 seconds (118.32 k allocations: 5.960 MiB, 7.66% compilation time)
GtkCssProviderLeaf()
julia> @time Gtk.CssProviderLeaf(data="#name {background:#C0C0C0;border-width:2px}")
3.968938 seconds (6 allocations: 96 bytes)
GtkCssProviderLeaf()这发生在Windows 10的版本1.8.1和版本1.8.2中。
发布于 2022-11-17 18:28:28
查看https://github.com/JuliaGraphics/Gtk.jl/blob/master/src/theme.jl中的函数
function GtkCssProviderLeaf(; data = nothing, filename = nothing)
source_count = (data !== nothing) + (filename !== nothing)
@assert(source_count <= 1,
"GtkCssProvider must have at most one data or filename argument")
provider = GtkCssProviderLeaf(ccall((:gtk_css_provider_new, libgtk), Ptr{GObject}, ()))
if data !== nothing
GError() do error_check
ccall((:gtk_css_provider_load_from_data, libgtk), Bool,
(Ptr{GObject}, Ptr{UInt8}, Clong, Ptr{Ptr{GError}}),
provider, bytestring(data), -1, error_check)
end
elseif filename !== nothing
GError() do error_check
ccall((:gtk_css_provider_load_from_path, libgtk), Bool,
(Ptr{GObject}, Ptr{UInt8}, Ptr{Ptr{GError}}),
provider, bytestring(filename), error_check)
end
end
return provider
end似乎延迟是在调用libgtk。您可能想看看是否可以将在您使用的代码中必须调用的时间减少到最小。
发布于 2022-11-18 09:26:09
谢谢比尔
朱莉娅的一位专家告诉我,答案很快:
julia> @time Gtk.CssProviderLeaf(data="#name {background:#C0C0C0;border-width:2px}")
0.000078 seconds (6 allocations: 96 bytes)我是他在Linux系统上运行的,问题是不是在Windows操作系统上?
https://stackoverflow.com/questions/74472061
复制相似问题