#!/bin/sh
# Copyright 1999-2002 Carnegie Mellon University.  
# Portions Copyright 2002 Sun Microsystems, Inc.  
# Portions Copyright 2002 Mitsubishi ElectricResearch Laboratories.
# All Rights Reserved.  Use is subject to license terms.
# 
# See the file "license.terms" for information on usage and
# redistribution of this file, and for a DISCLAIMER OF ALL 
# WARRANTIES.
#
# Collects S4 metrics
# 
#
# usage:  collectMetrics
#
# This should be run from the regression test directory
#
# Outputs the following metrics:
#
# 'metrics' - the record tag
# date - the date the metrics were collected
# fileCount - the number of files in the workspace
# javaFileCount - the number of java files in the workspace
# classCount - the number of java classes
# lineCount - the number of source lines of java code
# packageCount - the number packages
#
# Output Format:
#
# metrics|fileCount|javaFileCount|classCount|lineCount|packageCount|


rootDir=../../

##### The date 
date=`date +%Y-%m-%d`

#### count all of the files

fileCount=`find $rootDir -type f | wc -l`

#### count all of the java files

javaFileCount=`find $rootDir -name "*.java" | wc -l`

#### count all of the classes

classCount=`find $rootDir -name "*.java" | xargs grep class | wc -l`

#### count all of the lines of code

lineCount=`find $rootDir -name "*.java" | xargs egrep "[{;]" | wc -l`

#### package count
packageCount=`find ../.. -name "*.java" -exec cat {} \; | grep "^package" | sort -u | wc -l`

echo "metrics|$date|$fileCount|$javaFileCount|$classCount|$lineCount|$packageCount|"
