static void Main(string[] args) { //TestExpressions(); Instrumentation.Time("Validate Customer", TestCustomerValidation); Instrumentation.Time("Validate Customer", DoSomeExpensiveOperation); WriteLine(); }
public DbLogger(ConnectionString connString, ILogger log) { //Connect = f => ConnectionHelper.Connect(connString, f); this.Connect = new Middleware <SqlConnection>(f => { return(ConnectionHelper.Connect <dynamic>(connString, f)); }); this.Time = new Func <String, Middleware <Unit> >(op => { return(new Middleware <Unit>(f => Instrumentation.Time(log, op, f.ToNullary()))); }); this.Trace = op => f => Instrumentation.Trace(log, op, f.ToNullary()); }
static void _main() { // call the overload that takes a Func<T> var contents = Instrumentation.Time("reading from file.txt" , () => File.ReadAllText("file.txt")); // explicitly call with Func<Unit> Instrumentation.Time("reading from file.txt", () => { File.AppendAllText("file.txt", "New content!", Encoding.UTF8); return(Unit()); }); // call the overload that takes an Action Instrumentation.Time("reading from file.txt" , () => File.AppendAllText("file.txt", "New content!", Encoding.UTF8)); }
public DbLogger(ConnectionString connString, ILogger log) { Connect = f => ConnectionHelper.Connect(connString, f); Time = op => f => Instrumentation.Time(log, op, f.ToNullary()); Trace = op => f => Instrumentation.Trace(log, op, f.ToNullary()); }
public void Log(LogMessage message) => Instrumentation.Time("CreateLog" , () => ConnectionHelper.Connect(connString , c => c.Execute("sp_create_log" , message, commandType: CommandType.StoredProcedure)));