From efbb1c744f2aff32b0ad72ff89af706cb7267df8 Mon Sep 17 00:00:00 2001 From: haleyyoung Date: Tue, 23 Jul 2013 11:03:18 -0700 Subject: [PATCH] Add ability to count sloc for each framework. Note for this to do anything, there has to be a source_code file in each framework folder. --- benchmarker.py | 122 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 122 insertions(+) diff --git a/benchmarker.py b/benchmarker.py index 750ecf4bbcf..575ac78a672 100644 --- a/benchmarker.py +++ b/benchmarker.py @@ -396,6 +396,8 @@ def __parse_results(self, tests): # Aggregate JSON file with open(os.path.join(self.full_results_directory(), "results.json"), "w") as f: f.write(json.dumps(self.results)) + with open(os.path.join(self.full_results_directory(), "slocCount.json"), "w") as f: + f.write(json.dumps(self.sloc)) # JSON CSV # with open(os.path.join(self.full_results_directory(), "json.csv"), 'wb') as csvfile: @@ -434,6 +436,126 @@ def __parse_results(self, tests): # End __parse_results ############################################################ + + ############################################################# + # __count_sloc + # This is assumed to be run from the benchmark root directory + ############################################################# + def __count_sloc(self): + all_folders = [ + "aspnet", + "aspnet-stripped", + "beego", + "bottle", + "cake", + "compojure", + "cowboy", + "cpoll_cppsp", + "dancer", + "dart", + "django", + "django-stripped", + "dropwizard", + "elli", + "express", + "finagle", + "flask", + "gemini", + "go", + "grails", + "grizzly-bm", + "grizzly-jersey", + "hapi", + "http-kit", + "HttpListener", + "jester", + "kelp", + "lapis", + "lift-stateless", + "luminus", + "mojolicious", + "nancy", + "netty", + "nodejs", + "onion", + "openresty", + "php", + "php-codeigniter", + "php-fuel", + "php-kohana", + "php-laravel", + "php-lithium", + "php-micromvc", + "php-phalcon", + "php-phalcon-micro", + "php-silex", + "php-silex-orm", + "php-silica", + "php-slim", + "php-symfony2", + "php-yaf", + "phreeze", + "plack", + "plain", + "play1", + "play1siena", + "play-java", + "play-java-jpa", + "play-scala", + "play-scala-mongodb", + "play-slick", + "rack", + "rails", + "rails-stripped", + "restexpress", + "revel", + "revel-jet", + "revel-qbs", + "ringojs", + "ringojs-convenient", + "scalatra", + "servicestack", + "servlet", + "sinatra", + "snap", + "spark", + "spray", + "spring", + "tapestry", + "tornado", + "treefrog", + "undertow", + "unfiltered", + "vertx", + "wai", + "webgo", + "web-simple", + "wicket", + "wsgi", + "yesod" + ] + + jsonResult = {"slocCount":{}} + + for framework in all_folders: + try: + command = "cloc --list-file=./" + framework + "/source_code --yaml" + lineCount = subprocess.check_output(command, shell=True) + # Find the last instance of the word 'code' in the yaml output. This should + # be the line count for the sum of all listed files or just the line count + # for the last file in the case where there's only one file listed. + lineCount = lineCount[lineCount.rfind('code'):len(lineCount)] + lineCount = lineCount.strip('code: ') + lineCount = lineCount[0:lineCount.rfind('comment')] + jsonResult["slocCount"][framework] = int(lineCount) + except: + continue + print jsonResult + self.sloc = jsonResult + ############################################################ + # End __count_sloc + ############################################################ + ############################################################ # __finish ############################################################