FW4与FW 3.5中DateTime.TryParseExact的性能问题

编程入门 行业动态 更新时间:2024-10-18 10:25:52
本文介绍了FW4与FW 3.5中DateTime.TryParseExact的性能问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

大家好

我遇到了fw3.5和4之间的一个有趣的性能问题

I comeacross aninteresting performance issue between fw3.5 and 4

当我在fw 4上运行此代码时,运行时间为8.39秒,但是在fw3.5上运行时,时间为0.34秒

when i run this code on fw 4 the running time is 8.39 sec but when running it on fw3.5 the time is 0.34 sec

Stopwatch stopWatch = new Stopwatch(); string formats = "%M/%d/yyyy %h:mm:%s:fff tt"; DateTime datetime = DateTime.Now; stopWatch.Start(); for (int i = 0; i < 10000; i++) { DateTime dateTime; bool isParsed = DateTime.TryParseExact( DateTime.Now.ToString(), formats, new CultureInfo("en-US"), DateTimeStyles.None, out dateTime); } stopWatch.Stop(); TimeSpan ts = stopWatch.Elapsed; string elapsedTime = String.Format("{0:00}:{1:00}.{2:00}", ts.Minutes, ts.Seconds, ts.Milliseconds / 10); Console.WriteLine("RunTime " + elapsedTime);

推荐答案

感兴趣...我检查了它. CultureInfo的实现方式有所不同:

Interessting... I checked it. CultureInfo is differently implemented:

1.)它在4.0中具有属性:

1.) It has a attribute in 4.0:

[SecuritySafeCritical, TargetedPatchingOptOut("Performance critical to inline across NGen image boundaries")] Whatever that means..

更多推荐

FW4与FW 3.5中DateTime.TryParseExact的性能问题

本文发布于:2023-11-07 19:42:36,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1567247.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:性能   FW   TryParseExact   DateTime

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!