- 浏览: 400070 次
- 性别:
- 来自: 上海
文章分类
- 全部博客 (309)
- xaml C# wpf (0)
- scala java inner clas (1)
- Tools UML Eclipse UML2 (1)
- Timer .NET Framework (1)
- perl (6)
- python function paramter (1)
- Python Docstring (1)
- Python how to compare types (1)
- Python (8)
- java (5)
- C# (76)
- C# WPF (0)
- p4 (0)
- WPF (46)
- .net (6)
- xaml (1)
- javascript (40)
- windows (10)
- scala (4)
- winform (1)
- c++ (48)
- tools (12)
- cmd (1)
- os (0)
- CI (0)
- shell (0)
- C (2)
- haskell (49)
- functional (1)
- tool (1)
- gnu (1)
- linux (1)
- kaskell (0)
- svn (0)
- wcf (3)
- android (1)
最新评论
To get time of nanoseconds accuracy, what you can do inside C# is to use the Stopwatch classes from the System.Stopwatch class.
below is the code that shows how to program on nanoseconds .
public static long NanoTime { get { return (long)(Stopwatch.GetTimestamp() / (Stopwatch.Frequency / 1000000000.0)); } }
There is a twiki on the nanosecond with the help of stopwatch. - How do you convert Stopwatch to nanoseconds, milliseconds and seconds...
While another possibly use of high definition of timer is through the DateTime class, the DateTime class does not provide the accuracy of Sotpwatch, but you can still get very high accurate of milli-seconds value.
The fact with DateTime is that DateTime has a Ticks propery, while the resolution of the DateTime.Ticks is known to be 100 nanoseconds. Also , we now Timespan has some readonly fields which is able to telll how many ticks are there in one milliseconds and how mnay ticks are there in one nanoseconds.
Is there a high resolution (microsecond, nanosecond) DateTime object available for the CLR?
There are some code that is taken from the discussion on that post.
/// <summary> /// /// </summary> /// <remarks> /// The resolution of the DateTimer.Tick is 100 nanosecond, with the help of /// /// </remarks> public static class DateTimeExtensionMethods { /// <summary> /// The number of ticks per microsecond. /// </summary> public const int TicksPerMicrosecond = 10; /// <summary> /// The number of ticks per Nanosecond. /// </summary> public const int NanosecondsPerTick = 100; /// <summary> /// Gets the microsecond fraction of a DateTime. /// </summary> /// <param name="self"></param> /// <returns></returns> public static int Microseconds(this DateTime self) { return (int)Math.Floor((self.Ticks % TimeSpan.TicksPerMillisecond) / (double)TicksPerMicrosecond); } /// <summary> /// Gets the Nanosecond fraction of a DateTime. Note that the DateTime /// object can only store nanoseconds at resolution of 100 nanoseconds. /// </summary> /// <param name="self">The DateTime object.</param> /// <returns>the number of Nanoseconds.</returns> public static int Nanoseconds(this DateTime self) { return (int)(self.Ticks % TimeSpan.TicksPerMillisecond % TicksPerMicrosecond) * NanosecondsPerTick; } /// <summary> /// Adds a number of microseconds to this DateTime object. /// </summary> /// <param name="self">The DateTime object.</param> /// <param name="microseconds">The number of milliseconds to add.</param> public static DateTime AddMicroseconds(this DateTime self, int microseconds) { return self.AddTicks(microseconds * TicksPerMicrosecond); } /// <summary> /// Adds a number of nanoseconds to this DateTime object. Note: this /// object only stores nanoseconds of resolutions of 100 seconds. /// Any nanoseconds passed in lower than that will be rounded using /// the default rounding algorithm in Math.Round(). /// </summary> /// <param name="self">The DateTime object.</param> /// <param name="nanoseconds">The number of nanoseconds to add.</param> public static DateTime AddNanoseconds(this DateTime self, int nanoSeconds) { return self.AddTicks((int)Math.Round(nanoSeconds / (double)NanosecondsPerTick)); } }
发表评论
-
wpf - example to enhance ComboBox for AutoComplete
2014-09-19 15:56 1977first let’s see an example ... -
Investigate and troubleshoot possible memory leak issue of .NET application
2014-07-31 10:42 0Hi All, I would like to sh ... -
C# – CoerceValueCallback合并、替换元数据值
2013-08-05 21:59 1926Topic: C# – CoerceValueCallbac ... -
wpf – ListView交替背景色
2013-07-02 20:56 6552Wpf – Alternate background col ... -
C# - 简单介绍TaskScheduler
2013-06-29 17:18 12046标题: C# - 简单介绍TaskSchedulerTit ... -
c# - Get enum from enum attribute
2013-06-27 21:32 1246DescriptionAttribute gives the ... -
C# - PInvoke, gotchas on the RegisterClassEx and the CreateWindowEx
2013-06-24 13:49 2574I get an exception message li ... -
c# - Use PInvoke to create simple win32 Application
2013-06-24 11:59 10948In this post, .net platform h ... -
c# - Linq's Select method as the Map function
2013-06-19 18:47 1288If you comes from a functiona ... -
c# - Tips of Linq expression Any to determine if a collection is Empty
2013-06-19 18:29 939When you are @ the linq expres ... -
myth buster - typeof accepting array of types not acceptable
2013-06-19 17:17 815I have seen from some book whe ... -
windows - trying to create WIN32 application with PInvoke
2013-06-19 14:34 0While it is stupid to do such ... -
WPF - Setting foreground color of Entire window
2013-06-13 16:00 1921You might as well as I would s ... -
WPF - Enhanced TabControl - TabControlEx aka Prerendering TabControl
2013-06-13 13:12 5332As an opening word, let's che ... -
wpf - ControlTemplate and AddLogicChild/RemoveLogicalChild
2013-06-10 15:42 1187Recently I was trying to debug ... -
c# - P/Invoke, DllImport, Marshal Structures and Type conversions
2013-06-05 15:25 1714P/Invoke as in the following q ... -
c# - A study on the NativeWindow - encapsulate window handle and procedure
2013-06-05 14:40 6096NativeWindow gives you a way t ... -
WCF - Notify server when client connects
2013-06-03 18:19 1224It is sometimes very importan ... -
wcf - Debug to enable Server exception in Fault message
2013-06-03 15:47 1093WCF will be able to send back ... -
c# - determine if a type/object is serialzable
2013-05-30 16:35 869In WCF, primitives type are s ...
相关推荐
ISO 1328-1是关于圆柱齿轮精确度的国际标准,它定义了与圆柱齿轮齿面相关的偏差的允许值。ISO国际标准化组织是世界各国国家标准机构的世界性联邦,负责通过技术委员会进行国际标准的准备工作。在技术委员会为某一...
FaceBoxes: A CPU Real-time Face Detector with High Accuracy 的论文 值得一看
One of the core features of C# is its type safety, which ensures that variables can only hold values of the types they were declared to hold. This helps prevent runtime errors and makes the code more ...
Kaggle M5预测精度2020 背景 资料库包含我的团队对2020年3月2日至6月30日在Kaggle举行的(即M5)的解决方案。请查看我的! 入门 克隆仓库: ...cd {path-to-dir}/Kaggle-M5-Forecasting-Accuracy-2020
### 高精度室内地理定位技术:协作到达时间(CToA) #### 技术背景与原理 协作到达时间(CToA)作为一种新兴的高精度室内地理定位技术,旨在为现有的基于IEEE 802.11/Wi-Fi的地理定位系统提供可扩展性。...
例如,`LocationRequest.create().setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY)`。 4. **请求位置更新**: 使用`FusedLocationProviderClient.getLastLocation()`获取最后已知位置。这是一个异步操作,结果...
APS006 APPLICATION NOTE CHANNEL EFFECTS ON COMMUNICATIONS RANGE AND TIME STAMP ACCURACY IN DW1000 BASED SYSTEMS
of revolution finite-difference time-domain (ADI-BOR-FDTD) method. Due to the singularity, some field components on and adjacent to the axis are treated especially. To verify the accuracy and ...
以下是几篇经典的 YOLOv系列论文,推荐阅读: YOLOv1: You Only Look Once: Unified, Real-Time Object Detection(CVPR 2016) ...本次是主要YOLOv4: Optimal Speed and Accuracy of Object Detection的代码
kaggle比赛m5-forecasting-accuracy数据集 calendar.csv-包含有关产品销售日期的信息。 sales_train_validation.csv-包含每个产品和商店的历史每日单位销售数据[d_1-d_1913] sample_submission.csv-提交的正确格式。...
Like a super-nova, it appeared from nowhere for the 1995 UNLV Annual Test of OCR Accuracy [1], shone brightly with its results, and then vanished back under the same cloak of secrecy under which it ...
To meet the high precision of time delay and pulse width in ABAB synchronization time sequencing, phase shift is implemented to achieve ns-scaled delay and width accuracy without restoring to high ...
This chapter includes a brief overview of ensemble learning in general and presents a critique on the utility of multi-objective evolutionary algorithms for their design.
为了准确识别位置,需要测量到达角度(AOA)或者等效的时间差到达(Time Difference of Arrival,简称TDOA)。利用光学方法测量AOA可以带来许多好处,比如超低损耗和巨大带宽,这使得测量具有高精度和对电磁干扰的...