Skip to content

Instantly share code, notes, and snippets.

@webcoyote
Last active August 29, 2015 14:22
Show Gist options
  • Select an option

  • Save webcoyote/a0e11799a91a2d967083 to your computer and use it in GitHub Desktop.

Select an option

Save webcoyote/a0e11799a91a2d967083 to your computer and use it in GitHub Desktop.
#!/bin/bash
set -e # crash on errors
set -u # crash on undefined variables
set -o pipefail # crash when intermediate program in pipe fails
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
mcs "$SCRIPT_DIR/timer.cs" "$@"
using System;
using System.Net;
using System.Threading;
using System.Diagnostics;
public static class Program {
public static void Main (string[] args) {
var lastTicks = Environment.TickCount;
var lastStop = Stopwatch.GetTimestamp();
while (true) {
System.Threading.Thread.Sleep(5000);
var currTicks = Environment.TickCount;
var currStop = Stopwatch.GetTimestamp();
System.Console.WriteLine(
"{0} {1:0.0} {2:0.0}",
DateTime.UtcNow,
(currTicks - lastTicks) / 1000f,
(currStop - lastStop) / 1000f / 10000f
);
lastTicks = currTicks;
lastStop = currStop;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment