Skip to content

Commit 5ef8629

Browse files
committed
submitter stats
1 parent 95973bd commit 5ef8629

File tree

3 files changed

+37
-0
lines changed

3 files changed

+37
-0
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@ To install or update LODA, please follow the [installation instructions](https:/
22

33
## [Unreleased]
44

5+
### Enhancements
6+
7+
* Generate submitter stats
8+
59
### v25.8.30
610

711
### Bugfixes

src/mine/stats.cpp

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
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");
2021
const std::string Stats::STEPS_HEADER("total,min,max,runs");
2122
const std::string Stats::SUMMARY_HEADER(
2223
"num_sequences,num_programs,num_formulas");
24+
const std::string SUBMITTERS_HEADER = "submitter,count";
2325

2426
void 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;

src/mine/stats.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ class Stats {
6060
std::map<Number, int64_t> num_constants;
6161
std::map<Operation, int64_t> num_operations;
6262
std::map<OpPos, int64_t> num_operation_positions;
63+
std::map<std::string, int64_t> num_programs_per_submitter;
6364
std::multimap<UID, UID> call_graph;
6465
std::vector<int64_t> num_programs_per_length;
6566
std::vector<int64_t> num_ops_per_type;

0 commit comments

Comments
 (0)