protected virtual NotificationSettingsCategoryDto GetEventSettings() { var eventNotificationTypes = new Enum[] { NotificationTypeEnum.EventUpdated, NotificationTypeEnum.EventHidden, NotificationTypeEnum.BeforeStart }; var notificationTypes = eventNotificationTypes .Concat(CommentNotificationTypes) .Append(NotificationTypeEnum.ActivityLikeAdded, NotificationTypeEnum.UserMention); return(new NotificationSettingsCategoryDto(IntranetActivityTypeEnum.Events, notificationTypes)); }
public void PerformanceTest() { int loops = 10000; var enumValues = new Enum[] { ByteEnum.TestEnum.Zero, Int16Enum.TestEnum.Positive, Int32Enum.TestEnum.Negative, Int64Enum.TestEnum.Negative, SByteEnum.TestEnum.Zero, UInt16Enum.TestEnum.Positive, UInt32Enum.TestEnum.Zero, UInt64Enum.TestEnum.Positive }; var flagEnumValues = new Enum[] { ByteEnum.TestFlags.Flag1, Int16Enum.TestFlags.Flag2, Int32Enum.TestFlags.Flag3, Int64Enum.TestFlags.Flag1and2, SByteEnum.TestFlags.Flag3, UInt16Enum.TestFlags.AllFlags, UInt32Enum.TestFlags.Flag1, UInt64Enum.TestFlags.Flag1 }; foreach (var enumValue in enumValues.Concat(flagEnumValues)) { EnumUtility.IsValidEnumValue(enumValue); } Stopwatch byStringFromEnumStopWatch = new Stopwatch(); byStringFromEnumStopWatch.Start(); for (int i = 0; i < loops; i++) { foreach (var enumValue in enumValues) { IsValidEnumValueByString(enumValue); } } byStringFromEnumStopWatch.Stop(); Stopwatch byStringFromFlagStopWatch = new Stopwatch(); byStringFromFlagStopWatch.Start(); for (int i = 0; i < loops; i++) { foreach (var enumValue in flagEnumValues) { IsValidEnumValueByString(enumValue); } } byStringFromFlagStopWatch.Stop(); Stopwatch byValueFromEnumStopWatch = new Stopwatch(); byValueFromEnumStopWatch.Start(); for (int i = 0; i < loops; i++) { foreach (var enumValue in enumValues) { EnumUtility.IsValidEnumValue(enumValue); } } byValueFromEnumStopWatch.Stop(); Stopwatch byValueFromFlagStopWatch = new Stopwatch(); byValueFromFlagStopWatch.Start(); for (int i = 0; i < loops; i++) { foreach (var enumValue in flagEnumValues) { EnumUtility.IsValidEnumValue(enumValue); } } byValueFromFlagStopWatch.Stop(); Console.WriteLine("ByString Enum: {0}", byStringFromEnumStopWatch.ElapsedMilliseconds); Console.WriteLine("ByString Flag: {0}", byStringFromFlagStopWatch.ElapsedMilliseconds); Console.WriteLine("ByValue Enum: {0}", byValueFromEnumStopWatch.ElapsedMilliseconds); Console.WriteLine("ByValue Flag: {0}", byValueFromEnumStopWatch.ElapsedMilliseconds); }