IsNullOrEmpty与IsNullOrWhiteSpace性能谁比较高呢?

在string都是空字符串的情况下:

IsNullOrWhiteSpace要比IsNullOrEmpty快大约 1~5倍左右

如果都是为null呢,谁比较快呢?

IsNullOrWhiteSpace稳定在3,而IsNullOrEmpty在1~12之间来回跳跃

如果有值呢,谁比较快?

IsNullOrWhiteSpace基本稳定在3左右,而IsNullOrEmpty跳动幅度比较大一些在3~50之间

测试代码如下:

如此看来IsNullOrWhiteSpace性能是要比IsNullOrEmpty高的多得多的。

但如果处理上万条,几十万条数据却是IsNullOrEmpty性能要高的。但是IsNullOrWhiteSpace相对比较稳定,IsNullOrEmpty跳动幅度比较大一些

IsNullOrEmpty与IsNullOrWhiteSpace性能比较的更多相关文章

  1. IsNullOrEmpty与IsNullOrWhiteSpace区别

    IsNullOrEmpty public static bool IsNullOrEmpty(String value) { return (value == null || value.Length ...

  2. 【源码分析】你必须知道的string.IsNullOrEmpty && string.IsNullOrWhiteSpace

    写在前面 之前自信撸码时踩了一次小坑,代码如下: private static void AppServer_NewMessageReceived(WebSocketSession session, ...

  3. IsNullOrEmpty和IsNullOrWhiteSpace的区别

    IsNullOrEmpty // string /// <summary>Indicates whether the specified string is null or an < ...

  4. C# IsNullOrEmpty与IsNullOrWhiteSpace

    IsNullOrEmpty:非空非NULL判断 IsNullOrWhiteSpace:非空非NULL非空格判断 后者优于前者 if (!string.IsNullOrWhiteSpace(valueE ...

  5. C#空值和null判断

    一.空值判断效率 string s = ""; if(s == ""){} if(s == string.Empty){} if (string.IsNullO ...

  6. c#常用方法和类

    1.  数据类型转换函数 Convert.ToXXX(); XXX.Parse(); XXX.TryParse(); 2. 日期相关的类与函数 获取系统当前日期(含时间):DateTime.Now 获 ...

  7. csharp: Setting the value of properties reflection

    using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; usin ...

  8. string类(二、常用string函数)

    常用string相关,参至System.String类: 1/ string.Length a.Length字符串长度 string a="a5"; //a.Length==2 s ...

  9. 判断字符串为空 为null

    str:string; delphi str.IsNullOrEmpty str.IsNullOrWhiteSpace TStringHelper for delphi only,c++ no use ...

随机推荐

  1. 【转载】2015 Objective-C 三大新特性 | 干货

    Overview 自 WWDC 2015 推出和开源 Swift 2.0 后,大家对 Swift 的热情又一次高涨起来,在羡慕创业公司的朋友们大谈 Swift 新特性的同时,也有很多像我一样工作上依然 ...

  2. 敏捷测试(4)--基于story的敏捷基础知识

    基于story的敏捷基础知识----需求管理(一) 基于story进行需求管理 (1)使用story模式来管理需求,将庞大的MRD划分为一个个合适粒度,且可独立交付的story(通常每个story能在 ...

  3. (NO.00001)iOS游戏SpeedBoy Lite成形记(四)

    下面我们来实现选手从起点开始移动到终点的代码. 首先在GameScene.h接口中添加matchRun方法: #import "CCNode.h" @interface GameS ...

  4. Android Support Design 控件 FloatingActionButton

    经常刚可以看到悬浮控件,比如印象笔记的下面那个绿色的悬浮按钮,这个控件非常简单也是来自Design Support Library中同理需要在android studio中加入依赖库:design库 ...

  5. redis学习资料

    http://www.it168.com/redian/redis/ http://down.51cto.com/data/836008 http://www.redis.cn/

  6. 【Coding算法导论】第4章:最大子数组问题

    Coding算法导论 本系列文章主要针对算法导论一书上的算法,将书中的伪代码用C++实现 代码未经过大量数据测试,如有问题,希望能在回复中指出! (一)问题描述 给定一个数组,求数组中连续的子数组的和 ...

  7. libevent之event_base

    event_base是libevent的事务处理框架,负责事件注册.删除等,属于Reactor模式中的Reactor. event_base结构体 event_base结构体定义于<event_ ...

  8. linux测试noatime对文件访问时间的影响

    linux测试noatime对文件访问时间的影响 文件(如abc)有3个时间: # stat abc Access: 2015-04-16 19:30:13.665970572 +0800 Modif ...

  9. 如何修改SpriteBuilder中的按钮禁用启用状态

    按钮的禁用状态和按钮的User Interaction Enabled属性并不相符. 后者设定的是按钮是否参与用户交互. 你不能直接在SpriteBuilder中编译按钮的禁用启用属性.除非你想给按钮 ...

  10. SurfaceView浅析

    什么是SurfaceView呢? 为什么是SurfaceView呢?Surface的意思是表层,表面的意思,那么SurfaceView就是指一个在表层的View对象.为什么 说是在表层呢,这是因为它有 ...