2022-02-12 20:38:07 +03:00
|
|
|
module main
|
|
|
|
|
|
|
|
import benchmark
|
|
|
|
import sim
|
|
|
|
import sim.args as simargs
|
|
|
|
import sim.img
|
|
|
|
|
|
|
|
fn main() {
|
2022-05-13 06:56:21 +03:00
|
|
|
args := simargs.parse_args(sequential: true)? as simargs.SequentialArgs
|
2022-02-12 20:38:07 +03:00
|
|
|
|
|
|
|
mut bmark := benchmark.start()
|
|
|
|
defer {
|
|
|
|
bmark.measure(@FN)
|
|
|
|
}
|
|
|
|
|
2022-05-13 06:56:21 +03:00
|
|
|
mut writer := img.ppm_writer_for_fname(args.filename, img.image_settings_from_grid(args.grid))?
|
2022-02-12 20:38:07 +03:00
|
|
|
defer {
|
|
|
|
writer.close()
|
|
|
|
}
|
|
|
|
|
|
|
|
handle_request := fn [mut writer] (request &sim.SimRequest) ? {
|
|
|
|
result := sim.compute_result(request)
|
|
|
|
pixel := img.compute_pixel(result)
|
|
|
|
return writer.handle_pixel(pixel)
|
|
|
|
}
|
|
|
|
|
|
|
|
sim.run(args.params, grid: args.grid, on_request: sim.SimRequestHandler(handle_request))
|
|
|
|
|
2022-05-13 06:56:21 +03:00
|
|
|
writer.write()?
|
2022-02-12 20:38:07 +03:00
|
|
|
}
|