daily pastebin goal
29%
SHARE
TWEET

Untitled

a guest Jun 23rd, 2018 67 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. using System;
  2. using NLog;
  3. using NLog.Targets;
  4. using NLog.Config;
  5. using Serilog;
  6. using Serilog.Sinks.File;
  7. namespace logspeedtest
  8. {
  9.     //nlog 4.5.6
  10.     //serilog 2.7.1
  11.     class MainClass
  12.     {
  13.         public static void Main(string[] args)
  14.         {
  15.             String sample = "On the other hand, we denounce with righteous indignation and dislike men who are so beguiled and demoralized by the charms of";
  16.  
  17.             var watch = System.Diagnostics.Stopwatch.StartNew();
  18.             nlog_test(sample,10000);
  19.             //serilog_test(sample,10000);
  20.  
  21.             watch.Stop();
  22.             var elapsedMs = watch.ElapsedMilliseconds;
  23.             Console.WriteLine("Time taken: " + elapsedMs + " ms");
  24.  
  25.         }
  26.         static void nlog_test(String sample, int count){
  27.             var config = new LoggingConfiguration();
  28.             var fileTarget = new FileTarget("target2")
  29.             {
  30.                 FileName = "${basedir}/nlog.log",
  31.                 //Layout = "${longdate} ${level} ${message}  ${exception}"
  32.             };
  33.             config.AddTarget(fileTarget);
  34.  
  35.             config.AddRuleForOneLevel(LogLevel.Info, fileTarget);
  36.             LogManager.Configuration = config;
  37.             Logger logger = LogManager.GetLogger("Example");
  38.             for (int i = 0; i < count;i++){
  39.                 logger.Info(sample);
  40.             }
  41.  
  42.  
  43.         }
  44.  
  45.         static void serilog_test(String sample, int count){
  46.             var log = new LoggerConfiguration()
  47.                 .WriteTo.File("serilog.log")
  48.                 .CreateLogger();
  49.            
  50.             for (int i = 0; i < count;i++){
  51.                 log.Information(sample);
  52.             }
  53.         }
  54.     }
  55. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top