77
88#include " eval/evaluator_inc.hpp"
99#include " lang/analyzer.hpp"
10+ #include " lang/comments.hpp"
1011#include " lang/parser.hpp"
1112#include " lang/program_util.hpp"
1213#include " seq/managed_seq.hpp"
@@ -20,6 +21,7 @@ const std::string Stats::PROGRAMS_HEADER("id,length,usages,inc_eval,log_eval");
2021const std::string Stats::STEPS_HEADER (" total,min,max,runs" );
2122const std::string Stats::SUMMARY_HEADER (
2223 " num_sequences,num_programs,num_formulas" );
24+ const std::string SUBMITTERS_HEADER = " submitter,count" ;
2325
2426void checkHeader (std::istream &in, const std::string &header,
2527 const std::string &file) {
@@ -213,6 +215,25 @@ void Stats::load(std::string path) {
213215 blocks.load (path + " blocks.asm" );
214216 }
215217
218+ {
219+ full = path + " submitters.csv" ;
220+ Log::get ().debug (" Loading " + full);
221+ std::ifstream submitters (full);
222+ num_programs_per_submitter.clear ();
223+ if (std::getline (submitters, line)) {
224+ if (line != SUBMITTERS_HEADER) {
225+ throw std::runtime_error (" unexpected header in " + full);
226+ }
227+ }
228+ while (std::getline (submitters, line)) {
229+ std::stringstream s (line);
230+ std::getline (s, k, ' ,' );
231+ std::getline (s, v);
232+ num_programs_per_submitter[k] = std::stoll (v);
233+ }
234+ submitters.close ();
235+ }
236+
216237 // TODO: remaining stats
217238
218239 auto cur_time = std::chrono::steady_clock::now ();
@@ -318,6 +339,13 @@ void Stats::save(std::string path) {
318339 blocks.save (path + " blocks.asm" );
319340 }
320341
342+ std::ofstream submitters (path + " submitters.csv" );
343+ submitters << SUBMITTERS_HEADER << " \n " ;
344+ for (const auto &e : num_programs_per_submitter) {
345+ submitters << e.first << sep << e.second << " \n " ;
346+ }
347+ submitters.close ();
348+
321349 Log::get ().debug (" Finished saving program stats" );
322350}
323351
@@ -334,6 +362,10 @@ void Stats::updateProgramStats(UID id, const Program &program) {
334362 num_programs_per_length.resize (num_ops + 1 );
335363 }
336364 num_programs_per_length[num_ops]++;
365+ auto submitter = Comments::getSubmitter (program);
366+ if (!submitter.empty ()) {
367+ num_programs_per_submitter[submitter]++;
368+ }
337369 OpPos o;
338370 o.len = program.ops .size ();
339371 o.pos = 0 ;
0 commit comments