GalSim-developers/GalSim — pull request #185 by rmjarvis (2012-06-06 22:26:18+00:00)
Title: #158 Speed up radii unit tests

This is a very short pull request (especially compared to my other recent two). I just redid the calculations to use xValue directly rather than use draw and then query pixel values (which are just the xValue at that position after all). So that massively speeds up the calculation. I even went two magnitudes down in precision (1.e-4 rather than 1.e-2) for the tests.

I also added timing routines to each of the unit tests so it is easy to see what is taking the most time:

```
$ time run_all_tests | grep time | sort -n -k 5
time for test_ConstImageView_array_constness = 0.00
time for test_Image_array_view = 0.00
time for test_Image_basic = 0.00
time for test_Image_binary_add = 0.00
time for test_Image_binary_divide = 0.00
time for test_Image_binary_multiply = 0.00
time for test_Image_binary_scalar_add = 0.00
time for test_Image_binary_scalar_divide = 0.00
time for test_Image_binary_scalar_multiply = 0.00
time for test_Image_binary_scalar_subtract = 0.00
time for test_Image_binary_subtract = 0.00
time for test_Image_inplace_add = 0.00
time for test_Image_inplace_divide = 0.00
time for test_Image_inplace_multiply = 0.00
time for test_Image_inplace_scalar_add = 0.00
time for test_Image_inplace_scalar_divide = 0.00
time for test_Image_inplace_scalar_multiply = 0.00
time for test_Image_inplace_scalar_subtract = 0.00
time for test_Image_inplace_subtract = 0.00
time for test_binomial_image = 0.00
time for test_binomial_rand = 0.00
time for test_ccdnoise_image = 0.00
time for test_ccdnoise_rand = 0.00
time for test_chi2_image = 0.00
time for test_chi2_rand = 0.00
time for test_gamma_image = 0.00
time for test_gamma_rand = 0.00
time for test_gaussian_image = 0.00
time for test_gaussian_rand = 0.00
time for test_kxky = 0.00
time for test_kxky_plusone = 0.00
time for test_poisson_image = 0.00
time for test_poisson_rand = 0.00
time for test_sbprofile_gaussian_properties = 0.00
time for test_uniform_image = 0.00
time for test_uniform_rand = 0.00
time for test_uniform_rand_reset = 0.00
time for test_weibull_image = 0.00
time for test_weibull_rand = 0.00
time for test_Image_subImage = 0.01
time for test_exponential_radii = 0.05
time for test_exponential_radii = 0.05
time for test_gaussian_radii = 0.05
time for test_gaussian_radii = 0.05
time for test_sbprofile_moffat_properties = 0.08
time for test_roll2d_circularity = 0.09
time for test_roll2d_fwdbck = 0.09
time for test_moments_basic = 0.11
time for test_sbprofile_shift = 0.11
time for test_sbprofile_smallshear = 0.11
time for test_sersic_radii = 0.11
time for test_shearest_precomputed = 0.13
time for test_doublegaussian_vs_refimg = 0.14
time for test_moffat_radii = 0.14
time for test_sbprofile_add = 0.14
time for test_moffat_radii = 0.15
time for test_roll2d_join = 0.16
time for test_simple_wavefront = 0.18
time for test_sbprofile_gaussian = 0.23
time for test_sbprofile_shearconvolve = 0.25
time for test_sersic_radii = 0.25
time for test_sbprofile_box = 0.30
time for test_sbprofile_realspace_shearconvolve = 0.30
time for test_sbprofile_moffat = 0.31
time for test_simple_mtf = 0.31
time for test_simple_ptf = 0.31
time for test_sbprofile_realspace_convolve = 0.34
time for test_doublegaussian_vs_sbadd = 0.35
time for test_wavefront_image_view = 0.38
time for test_real_galaxy_saved = 0.41
time for test_psf_image_view = 0.42
time for test_consistency_psf_mtf = 0.43
time for test_sbprofile_convolve = 0.46
time for test_otf_image_view = 0.53
time for test_mtf_image_view = 0.54
time for test_ptf_image_view = 0.64
time for test_sbprofile_exponential = 0.65
time for test_sbprofile_realspace_distorted_convolve = 0.69
time for test_Lanczos7_spline = 0.73
time for test_Lanczos5_spline = 0.75
time for test_Cubic_spline = 0.78
time for test_real_galaxy_ideal = 0.78
time for test_Image_FITS_IO = 0.79
time for test_Quintic_spline = 0.84
time for test_sbprofile_rotate = 0.87
time for test_check_all_contiguous = 1.07
time for test_sbprofile_sersic = 1.09
time for test_sbprofile_airy = 1.33
time for test_sbprofile_largeshear = 1.44
time for test_sbprofile_mag = 1.55
time for test_sbprofile_sbinterpolatedimage = 1.69
time for test_shearest_basic = 2.92
time for test_sbprofile_rescale = 3.63
time for test_OpticalPSF_flux = 10.14
time for test_OpticalPSF_vs_Airy = 10.43
time for test_OpticalPSF_vs_Airy_with_obs = 12.13

real	1m6.926s
user	1m4.250s
sys	0m2.442s
```
So the three test_OpticalPSF unit tests are now taking approximately half of the total time of a `scons tests` command. But that's for a different issue... :)