lab.c

experiments

Try The Trade-Offs Yourself

This page turns the comparison into tools instead of paragraphs. Pick a workload, assign weights, and simulate what happens when allocation pressure climbs in a latency-sensitive system.

compare.cpp

Same Task, Different Runtime Story

#include <fstream>
#include <iostream>
#include <string>

int main() {
    std::ifstream input("app.log");
    std::string line;
    std::size_t errors = 0;

    while (std::getline(input, line)) {
        if (line.find("ERROR") != std::string::npos) {
            ++errors;
        }
    }

    std::cout << errors << '\n';
}
compare.java

Managed Version

import java.io.BufferedReader;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;

public class LogCount {
    public static void main(String[] args) throws IOException {
        long errors = 0;
        try (BufferedReader input =
                Files.newBufferedReader(Path.of("app.log"))) {
            String line;
            while ((line = input.readLine()) != null) {
                if (line.contains("ERROR")) {
                    errors++;
                }
            }
        }
    }
}
selector.cfg
recommendation.out
weights.cfg
score.out
gc_sim.c

Move the slider to simulate a workload that allocates more transient objects during a real-time loop.