Skip to content

Instantly share code, notes, and snippets.

@mauropm
Created May 24, 2026 02:23
Show Gist options
  • Select an option

  • Save mauropm/a1428e04328f03b9d0f68a1c7bd28a22 to your computer and use it in GitHub Desktop.

Select an option

Save mauropm/a1428e04328f03b9d0f68a1c7bd28a22 to your computer and use it in GitHub Desktop.
Mandelbrot - Performance prompt for testing new code generator tool

You are a senior Go engineer.

Implement a high-performance Go program that calculates the Mandelbrot set and renders it as a PNG image.

Requirements:

  • Use pure Go standard library only.
  • Support configurable image size, max iterations, and output filename via CLI flags.
  • Parallelize computation using goroutines and worker pools.
  • Optimize memory allocations and avoid unnecessary copying.
  • Generate a grayscale PNG output.
  • Add benchmarks for the core computation.
  • Add unit tests for escape-time calculations.
  • Organize code cleanly with:
    • cmd/
    • internal/
    • pkg/
  • Include a README explaining:
    • architecture
    • concurrency model
    • optimization decisions
    • how to run benchmarks

Extra challenge:

  • Add SIMD-like optimization ideas in comments.
  • Compare static vs dynamic worker scheduling.
  • Print total render time and pixels/sec.

The code should be production-quality and compile with: go build ./...

Then explain:

  1. Time complexity
  2. Memory behavior
  3. Concurrency tradeoffs
  4. Possible GPU offloading approaches
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment