Jan 15, 2010

Test & Code Edit Patterns

I put together a Groovy script to monitor my coding pattern of behaviour. The idea is that I can monitor when I last changed a source file or a test source file. Initially I plan to record a few days of data and graph it. My grand plan is to use my Arduino to drive some LEDs to tell me how long it's been and indicate when I've spent to long coding, writing tests, etc.

newestTest = 0
newestCode = 0

def walk(root) {
root.eachFile { file ->
if (file.name.endsWith(".java")) {
if (file.name.endsWith("Test.java")) {
newestTest = Math.max(newestTest, file.lastModified())
} else {
newestCode = Math.max(newestCode, file.lastModified())
}
}
}
root.eachDir { dir ->
if (!dir.name.startsWith(".")) {
walk(dir)
}
}
}

walk(new File(""))

def now = System.currentTimeMillis()
def code = (now - newestCode)/60000
def test = (now - newestTest)/60000

println "Test (minutes old): $test"
println "Code (minutes old): $code"

0 comments: