<commit_before>#!/usr/bin/env julia

import Celeste: ParallelRun
import Celeste.SDSSIO: RunCamcolField


const datadir = joinpath(Pkg.dir("Celeste"), "test", "data")
wd = pwd()
cd(datadir)
run(`make`)
cd(wd)


"""
test infer with a single (run, camcol, field).
This is basically just to make sure it runs at all.
"""
function benchmark_infer()
    # Warm up---this compiles the code
    box_compile = ParallelRun.BoundingBox(164.39, 164.40, 39.11, 39.13)
    field_triplets_compile = [RunCamcolField(3900, 6, 269),]
    ParallelRun.one_node_infer(field_triplets_compile, datadir; box=box_compile)

    # clear allocations in case julia is running with --track-allocations=user
    Profile.clear_malloc_data()

    # very small patch of sky that turns out to have 4 sources.
    # We checked that this patch is in the given field.
    box = ParallelRun.BoundingBox(164.39, 164.41, 39.11, 39.13)
    field_triplets = [RunCamcolField(3900, 6, 269),]

    if isempty(ARGS)
        # takes 6.4 seconds as of 11/5/2016 on an Intel Core i5-6600 processor
        @time ParallelRun.one_node_infer(field_triplets, datadir; box=box)
    elseif ARGS[1] == "--profile"
        Profile.clear_malloc_data()
        # about half the run time is psf fitting, the other half is elbo evaluation
        @profile ParallelRun.one_node_infer(field_triplets, datadir; box=box)
        Profile.print(format=:flat, sortedby=:count)
    end
end


benchmark_infer()<commit_msg>made benchmark_infer.jl more representative of actual runtime by not counting image and catalog loading<commit_after>#!/usr/bin/env julia

import Celeste.ParallelRun: one_node_single_infer, infer_init, BoundingBox
import Celeste.SDSSIO: RunCamcolField, load_field_images
import Celeste.Infer: find_neighbors


const datadir = joinpath(Pkg.dir("Celeste"), "test", "data")
wd = pwd()
cd(datadir)
run(`make`)
cd(wd)


"""
test infer with a single (run, camcol, field).
This is basically just to make sure it runs at all.
"""
function benchmark_infer()
    # very small patch of sky that turns out to have 4 sources.
    # We checked that this patch is in the given field.
    box = BoundingBox(164.39, 164.41, 39.11, 39.13)
    rcfs = [RunCamcolField(3900, 6, 269),]

    catalog, target_sources = infer_init(rcfs, datadir; box=box)
    images = load_field_images(rcfs, datadir)
    neighbor_map = find_neighbors(target_sources, catalog, images)

    # Warm up---this compiles the code
    one_node_single_infer(catalog, target_sources, neighbor_map, images)

    # clear allocations in case julia is running with --track-allocations=user
    Profile.clear_malloc_data()

    if isempty(ARGS)
        @time one_node_single_infer(catalog, target_sources, neighbor_map, images)
    elseif ARGS[1] == "--profile"
        Profile.clear_malloc_data()
        # about half the run time is psf fitting, the other half is elbo evaluation
        @profile one_node_single_infer(catalog, target_sources, neighbor_map, images)
        Profile.print(format=:flat, sortedby=:count)
    end
end


benchmark_infer()
{'fraction_non_alphanumeric': 0.09940944881889764, 'fraction_numerical': 0.031496062992125984, 'mean_word_length': 4.023064250411862, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4103543', 'n_tokens_mistral': 1094, 'n_tokens_neox': 988, 'n_words': 296}