更新
我已经更新了应用程序启动时运行的代码示例,并上传了性能配置文件结果的新图像。我不明白第一秒没有活动的原因。这似乎是最严重的延迟,我想了解这是 WPF 还是 dot net 框架在做什么?
结束更新
在 UI 线程利用率图中,我可以看到在磁盘 IO(蓝线)之前,又大部分是空白 + 应用程序代码(绿色)。我怎样才能知道空白区域发生了什么?
我看到的另一件事是 XAML 在应用程序加载时被解析(蓝色区域)。xaml 存在于不同的项目中,并在此处引用。我想知道是否有任何方法可以预先解析 xaml,因为它位于不同的项目中。
我知道这个问题有点太宽泛,但是有关如何继续的建议或指向正确工具(最好是免费的)的建议将很有价值。
我的 App.XAML 仅包含:
protected override void OnStartup(StartupEventArgs e)
{
new Entry().Show();
base.OnStartup(e);
}
Run Code Online (Sandbox Code Playgroud)
Entry的XAML是
<telerik:RadWindow x:Class="Some.Namespace.Entry"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"
xmlns:local="clr-namespace:Some.Namespace"
mc:Ignorable="d"
Header ="Header" Width="1700" Height="900"
telerik:StyleManager.Theme="Windows8" WindowStartupLocation="CenterOwner">
</telerik:RadWindow>
Run Code Online (Sandbox Code Playgroud)
背后的代码:
public Entry()
{
RadWindowInteropHelper.SetAllowTransparency(this, false);
InitializeComponent();
}
Run Code Online (Sandbox Code Playgroud)
UPDATE TcpView 没有显示任何网络流量(我没想到这一点)。关闭恶意软件可能不可行。我确实尝试使用 Jet Brains profiler 获取另一份报告,这表明几乎一秒钟的时间都花在验证访问上,这是否合理,尝试在网上找到更多信息但没有得到任何结果。
split :: [a] -> Int -> ([a], [a])
split [xs] n =
(take n [xs], drop n [xs])
Run Code Online (Sandbox Code Playgroud)
如果我将变量xs改为代替,则相同的代码可以工作[xs],签名在两种情况下都相同.使用[xs]给出了模式非穷举的错误.我理解这说明我提供的输入不在我的代码中,但不清楚幕后发生了什么.
测试输入:[1,2,3] 2.
我正在尝试使用foldr实现我自己的groupBy函数(类似于Prelude的函数).
以下定义似乎有效:
myGroupBy p xs = foldr step [] xs
where step x acc
| null acc = [[x]]
| p x (head (head acc)) = (x:head acc):(tail acc)
| otherwise = [x]:acc
Run Code Online (Sandbox Code Playgroud)
由于我head acc/tail acc多次使用,虽然我可以通过使用as-pattern来改进它.所以我改为:
myGroupByNew p xs = foldr step [] xs
where step x acc@(a:b)
| null acc = [[x]]
| null b = [[x]]
| p x (head a) = (x:a):b
| otherwise = [x]:acc
Run Code Online (Sandbox Code Playgroud)
但是,这种方法现在给了我一个非详尽的模式错误.我不明白,我已经检查null acc和null b,所以假设a不能为空.至于x,也没有在前面的方法中为它添加任何保护条款. …
我理解(有些)monad并理解运算符< - 将从monad中提取值.
但它如何适用于不同类型?
通常,我已经看到它被用于从IO monad中提取字符串.但是在下面的示例代码中,我无法看到它为什么在主要的第3行失败,抱怨它期待一种类型的IO int?编译器如何推断需要IO int?
它(<-)在multWithLog方法中做了什么?
import Control.Monad.Trans.Writer.Lazy
main = do
putStrLn $ show $ logNumber 3 -- prints WriterT (Identity (3,["Got Number: 3"]))
putStrLn $ show $ multWithLog -- prints WriterT (Identity (3,["Got Number: 3"]))
_ <- logNumber 3 -- fails with Couldn't match type ‘WriterT [String] Data.Functor.Identity.Identity’ with ‘IO’
-- Expected type: IO Int
-- Actual type: Writer [String] Int
putStrLn "test"
logNumber :: Int -> Writer [String] Int
logNumber x …Run Code Online (Sandbox Code Playgroud) 我正在尝试将(数字)字符串转换为单个数字。有多种解决方法,一种是map digitToInt "1234"
我正在尝试类似的方法,但是没有digitToInt尝试使用,而是尝试使用该read::Char->Int函数。但是,当我使用上述方法时,出现编译错误,如下所示:
map (read::Char->Int) ['1','2']
Run Code Online (Sandbox Code Playgroud)
给我下面给出的以下错误。我不确定这里出了什么问题,我正在尝试映射一个将Char替换为Char列表的函数,我还缺少什么?
请不要告诉我其他方法,因为我了解还有其他几种方法可以做到这一点。只想了解这里发生了什么。
Couldn't match type ‘Char’ with ‘[Char]’
Expected type: Char -> Int
Actual type: String -> Int
• In the first argument of ‘map’, namely ‘(read :: Char -> Int)’
Run Code Online (Sandbox Code Playgroud) 我本以期待show.fst (1,2)工作.但我很惊讶地发现它有例外.
在运行单个fst (1,2)返回1::Num a => a并show 1打印出1作为字符串
show.fst $ (1,2)
Run Code Online (Sandbox Code Playgroud)
工作良好.这更令人困惑,因为我没有看到如何进一步减少元组(据我所知,当我们想要评估表达式的正确部分时使用$运算符.