Skip to content

Instantly share code, notes, and snippets.

@carlosmn
Created March 22, 2014 13:56
Show Gist options
  • Save carlosmn/9707518 to your computer and use it in GitHub Desktop.
Save carlosmn/9707518 to your computer and use it in GitHub Desktop.
Counting authors
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