lab0-c icon indicating copy to clipboard operation
lab0-c copied to clipboard

Add graph plotting for dudect analysis

Open SimonLiu423 opened this issue 9 months ago • 2 comments

Implement graph generation using "gnuplot" for dudect to visualize t-statistic measurements.

  • Add "plot.c" and "plot.h" files to support graphing, "plot.c" stores each measurements execution time in "data_buffer". When plot_graph() is called, stores the data to file and generates a "gnuplot" script. I try to replicate the graph shown in "dudect's" paper "Dude, is my code constant time?".

  • Modify "fixture.c" to integrate with new plotting functionality.

  • Move definition of ENOUGH_MEASURE and TEST_TRIES from "fixture.c" to "fixture.h" for "plot.c" to access and specify size of "data_buffer"

  • Update "Makefile" to include plot.o in build

This enhancement allows visual representation of constant-time analysis results, making it easier to interpret dudect test outcomes.

SimonLiu423 avatar Mar 09 '25 08:03 SimonLiu423

TODO:

  • detect if gnuplot is installed on machine
  • update github workflow to add support for plotting
  • combine multiple plots into one single image

Known Issue:

  • While generating the gnuplot script, sprintf is used to dynamically set the label. It is a command provided by gnuplot. However, the pre-commit.hook would stop us from committing since sprintf is detected to be a dangerous function.

SimonLiu423 avatar Mar 09 '25 08:03 SimonLiu423

the pre-commit.hook would stop us from committing since sprintf is detected to be a dangerous function.

You can send another pull request which limits the detection of sprintf only to C source files.

jserv avatar Mar 09 '25 09:03 jserv