1. pivotal
  2. tgrep

Overview

Hello -

tgrep is a project I implemented for this programming challenge that reddit put out: http://www.reddit.com/r/blog/comments/fjgit 

Specifically, it was for the backend challenge. Basically a program to search for timestamps in a log file. 
It uses a binary search that is slightly modified to take into account overlapping day timestamps.

My first implementation was in Python 2.6, and it does pretty well head to head against grep, with an advantage as file size goes up.
(sample4.log is ~570M)

[snpxw@PWadeiMAC:reddit_log ]$ time python tgrep.py 00:10:54 sample4.log
( search results ... )
real    0m0.143s
user    0m0.025s
sys     0m0.014s

[snpxw@PWadeiMAC:reddit_log ]$ time grep 00:10:54 sample4.log
( search results ... )
real    0m8.676s
user    0m0.324s
sys     0m0.394s

As a project for myself, I thought I would re-implement it in both Python 3 and C.

The Python 3 port really wasn't difficult - the 2to3 utility did all the work. However, it does run a bit slower
than the original, so perhaps I should look into hand tuning it.

Right now I'm working on the C version, which is tough (I'm learning C as I go), but quite a bit of fun.

Thanks for checking it out!
Phil

Contact:
you can send me an email at phil@philwade.org