Created
March 22, 2014 13:56
-
-
Save carlosmn/9707518 to your computer and use it in GitHub Desktop.
Counting authors
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Diagnostics; | |
using System.Collections.Generic; | |
using System.Linq; | |
using LibGit2Sharp; | |
namespace list | |
{ | |
class MainClass | |
{ | |
public static void Main (string[] args) | |
{ | |
Console.WriteLine ("Hello World!"); | |
var sw = new Stopwatch(); | |
sw.Start(); | |
var counts = new Dictionary<string, int>(); | |
using (var repo = new Repository("/home/carlos/linux/linux")) | |
{ | |
foreach (var author in repo.Commits.Select(c => c.Author)) { | |
int count; | |
if (!counts.TryGetValue(author.Name, out count)) | |
counts.Add(author.Name, 1); | |
else | |
counts[author.Name] = count + 1; | |
} | |
} | |
sw.Stop(); | |
Console.WriteLine((double)Process.GetCurrentProcess().PagedMemorySize64 / 1024.0 / 1024.0); | |
Console.WriteLine( "Took {0}ms", sw.ElapsedMilliseconds); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment