ENCCS/python-perf

Feedback after mini-workshop on 2024.09.26

Opened this issue · 3 comments

Timing notes

  • Opening note on ENCCS can take a few minutes, but I was unprepared.
  • Installation took a good 15 minutes - unsure.
  • Intro and perf. fundamentals episodes took a long time, but more on that later
  • Start to end of profiling episode was around 1 hour 20 minutes.
  • Optimization episode was done quickly without a demo and it still took 15 minutes.
  • Parallelizing was skipped.

Possible improvements

  • Spread theory part (intro and perf. fundamentals) into discussion points along at the end of hands-on episodes. This will allow us to get to the practical aspects quicker and appreciate the context of the theory.

Technical problems

  • Move pip install instruction from footer to the main page along with conda - most learners had either Linux or macOS.
  • Remove mpi4py - we are not using it and installing it with pip requires a working mpi library.
  • Python Tutor demo does not add any value, it can be removed
  • Also in the code, change f.readlines() to f, since using readlines would create a list of the whole file and the latter is an iterator. Otherwise the discussion topic is confusing.
import io

def rms_from_text_file(f):
    """Compute root-mean-square of comma-separated values."""
    rms = 0
    n_samples = 0
    
    for line in f.readlines():
        fields = line.split(",")
        x, y, z = float(fields[0]), float(fields[1]), float(fields[2])
        # compute root-mean-square value
        rms += ((x**2 + y**2 + z**2) / 3) ** 0.5
        n_samples += 1
        
    return rms / n_samples


fake_file = io.StringIO("""\
0.27194615,0.85939776,0.76905204
0.51586611,0.59174447,0.06501842
0.23109192,0.8260391,0.08045166
""")

avg_rms = rms_from_text_file(fake_file)