Skip to content

Commit 12c9618

Browse files
kalidkeclaude
andcommitted
Change timing field from elapsed_ns to elapsed_s
- SimInfo.elapsed_s::Float64 (was elapsed_ns::UInt64) - ImageInfo.elapsed_s::Float64 (was elapsed_ns::UInt64) - Time now stored directly in seconds for convenience Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent ee26058 commit 12c9618

File tree

8 files changed

+25
-25
lines changed

8 files changed

+25
-25
lines changed

api_overview.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ Metadata and intermediate results from simulation functions. Returned as the sec
127127

128128
```julia
129129
struct SimInfo
130-
elapsed_ns::UInt64 # Wall-clock time in nanoseconds
130+
elapsed_s::Float64 # Wall-clock time in nanoseconds
131131
backend::Symbol # Computation backend (:cpu)
132132
device_id::Int # Device identifier (-1 for CPU)
133133
seed::Union{UInt64, Nothing} # RNG seed for reproducibility
@@ -146,7 +146,7 @@ Metadata from image generation functions. Returned as the second element of the
146146

147147
```julia
148148
struct ImageInfo
149-
elapsed_ns::UInt64 # Wall-clock time in nanoseconds
149+
elapsed_s::Float64 # Wall-clock time in nanoseconds
150150
backend::Symbol # Computation backend (:cpu)
151151
device_id::Int # Device identifier (-1 for CPU)
152152
frames_generated::Int # Number of frames generated
@@ -372,7 +372,7 @@ smld, info = simulate(
372372
)
373373

374374
# Check timing
375-
println("Simulation took $(info.elapsed_ns / 1e9) seconds")
375+
println("Simulation took $(info.elapsed_s) seconds")
376376
```
377377

378378
#### kinetic_model
@@ -440,7 +440,7 @@ images, info = gen_images(
440440
)
441441

442442
# Access image metadata
443-
println("Generated $(info.frames_generated) frames in $(info.elapsed_ns / 1e9) seconds")
443+
println("Generated $(info.frames_generated) frames in $(info.elapsed_s) seconds")
444444
println("Total photons: $(info.n_photons_total)")
445445

446446
# The support parameter controls PSF computation region:
@@ -738,7 +738,7 @@ images, img_info = gen_images(smld_model, psf;
738738
)
739739

740740
println("Generated $(length(smld_noisy.emitters)) localizations and $(img_info.frames_generated) images.")
741-
println("Simulation took $(info.elapsed_ns / 1e9) seconds")
741+
println("Simulation took $(info.elapsed_s) seconds")
742742
```
743743

744744
### Diffusion with Dimer Analysis

src/camera_images/gen_images.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,11 +131,11 @@ function gen_images(smld::SMLD, psf::AbstractPSF;
131131
end
132132
end
133133

134-
elapsed_ns = time_ns() - start_time
134+
elapsed_s = (time_ns() - start_time) / 1e9
135135

136136
# Build ImageInfo
137137
info = ImageInfo(
138-
elapsed_ns=elapsed_ns,
138+
elapsed_s=elapsed_s,
139139
backend=:cpu,
140140
device_id=-1,
141141
frames_generated=length(frames),

src/diffusion/smoluchowski.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -488,14 +488,14 @@ function simulate(params::DiffusionSMLMParams;
488488
# Convert to SMLD
489489
smld = create_smld(camera_emitters, camera, params)
490490

491-
elapsed_ns = time_ns() - start_time
491+
elapsed_s = (time_ns() - start_time) / 1e9
492492

493493
# Calculate number of frames
494494
n_frames = isempty(smld.emitters) ? 0 : maximum(e.frame for e in smld.emitters)
495495

496496
# Build SimInfo (diffusion doesn't have smld_true/smld_model)
497497
info = SimInfo(
498-
elapsed_ns=elapsed_ns,
498+
elapsed_s=elapsed_s,
499499
backend=:cpu,
500500
device_id=-1,
501501
seed=nothing,

src/static/simulation.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -228,11 +228,11 @@ function simulate(params::StaticSMLMParams;
228228
# Add localization noise with appropriate PSF scaling
229229
smld_noisy = apply_noise(smld_model, σ_scaled)
230230

231-
elapsed_ns = time_ns() - start_time
231+
elapsed_s = (time_ns() - start_time) / 1e9
232232

233233
# Build SimInfo
234234
info = SimInfo(
235-
elapsed_ns=elapsed_ns,
235+
elapsed_s=elapsed_s,
236236
backend=:cpu,
237237
device_id=-1,
238238
seed=nothing,

src/types.jl

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ following the tuple-pattern convention: (primary_output, info).
1111
Metadata and intermediate results from simulation functions.
1212
1313
# Fields
14-
- `elapsed_ns::UInt64`: Wall-clock time for simulation in nanoseconds
14+
- `elapsed_s::Float64`: Wall-clock time for simulation in seconds
1515
- `backend::Symbol`: Computation backend (`:cpu`)
1616
- `device_id::Int`: Device identifier (-1 for CPU)
1717
- `seed::Union{UInt64, Nothing}`: RNG seed for reproducibility (if applicable)
@@ -25,7 +25,7 @@ Metadata and intermediate results from simulation functions.
2525
# Example
2626
```julia
2727
smld_noisy, info = simulate(params)
28-
println("Simulation took \$(info.elapsed_ns / 1e9) seconds")
28+
println("Simulation took \$(info.elapsed_s) seconds")
2929
println("Generated \$(info.n_localizations) localizations from \$(info.n_emitters) emitters")
3030
3131
# Access intermediate results for analysis
@@ -36,7 +36,7 @@ end
3636
"""
3737
struct SimInfo
3838
# Common fields (ecosystem convention)
39-
elapsed_ns::UInt64
39+
elapsed_s::Float64
4040
backend::Symbol
4141
device_id::Int
4242

@@ -56,7 +56,7 @@ end
5656

5757
# Convenience constructor with defaults
5858
function SimInfo(;
59-
elapsed_ns::UInt64=UInt64(0),
59+
elapsed_s::Float64=0.0,
6060
backend::Symbol=:cpu,
6161
device_id::Int=-1,
6262
seed::Union{UInt64, Nothing}=nothing,
@@ -67,7 +67,7 @@ function SimInfo(;
6767
n_localizations::Int=0,
6868
n_frames::Int=0
6969
)
70-
SimInfo(elapsed_ns, backend, device_id, seed, smld_true, smld_model,
70+
SimInfo(elapsed_s, backend, device_id, seed, smld_true, smld_model,
7171
n_patterns, n_emitters, n_localizations, n_frames)
7272
end
7373

@@ -77,7 +77,7 @@ end
7777
Metadata from image generation functions.
7878
7979
# Fields
80-
- `elapsed_ns::UInt64`: Wall-clock time for image generation in nanoseconds
80+
- `elapsed_s::Float64`: Wall-clock time for image generation in seconds
8181
- `backend::Symbol`: Computation backend (`:cpu`)
8282
- `device_id::Int`: Device identifier (-1 for CPU)
8383
- `frames_generated::Int`: Number of frames generated
@@ -87,13 +87,13 @@ Metadata from image generation functions.
8787
# Example
8888
```julia
8989
images, info = gen_images(smld, psf)
90-
println("Generated \$(info.frames_generated) frames in \$(info.elapsed_ns / 1e9) seconds")
90+
println("Generated \$(info.frames_generated) frames in \$(info.elapsed_s) seconds")
9191
println("Total photons: \$(info.n_photons_total)")
9292
```
9393
"""
9494
struct ImageInfo
9595
# Common fields
96-
elapsed_ns::UInt64
96+
elapsed_s::Float64
9797
backend::Symbol
9898
device_id::Int
9999

@@ -105,12 +105,12 @@ end
105105

106106
# Convenience constructor with defaults
107107
function ImageInfo(;
108-
elapsed_ns::UInt64=UInt64(0),
108+
elapsed_s::Float64=0.0,
109109
backend::Symbol=:cpu,
110110
device_id::Int=-1,
111111
frames_generated::Int=0,
112112
n_photons_total::Float64=0.0,
113113
output_size::Tuple{Int,Int,Int}=(0,0,0)
114114
)
115-
ImageInfo(elapsed_ns, backend, device_id, frames_generated, n_photons_total, output_size)
115+
ImageInfo(elapsed_s, backend, device_id, frames_generated, n_photons_total, output_size)
116116
end

test/test_camera_images.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424

2525
# Check ImageInfo
2626
@test isa(info, ImageInfo)
27-
@test info.elapsed_ns > 0
27+
@test info.elapsed_s > 0
2828
@test info.backend == :cpu
2929
@test info.frames_generated == 2
3030
@test info.n_photons_total == 3800.0 # 1000 + 2000 + 800
@@ -160,7 +160,7 @@ end
160160
@test smld_scmos.camera isa SCMOSCamera
161161
@test !isempty(smld_scmos.emitters)
162162
@test isa(info_scmos, SimInfo)
163-
@test info_scmos.elapsed_ns > 0
163+
@test info_scmos.elapsed_s > 0
164164

165165
# Test default behavior (should create IdealCamera)
166166
smld_default, info_default = simulate(params; override_count=5)

test/test_diffusion.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@
5959

6060
# Check SimInfo
6161
@test isa(info, SimInfo)
62-
@test info.elapsed_ns > 0
62+
@test info.elapsed_s > 0
6363
@test info.backend == :cpu
6464
@test info.n_emitters > 0
6565

test/test_static.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
@test isa(smld_model, BasicSMLD)
3434

3535
# Check info fields
36-
@test info.elapsed_ns > 0
36+
@test info.elapsed_s > 0
3737
@test info.backend == :cpu
3838
@test info.n_frames == 20
3939

0 commit comments

Comments
 (0)