The next technological breakthrough in millimeter-submillimeter astronomy is threedimensional imaging spectrometry with wide instantaneous spectral bandwidths and wide fields of view. The total optimization of the focal-plane instrument, the telescope, the observing strategy, and the signal-processing software must enable efficient removal of foreground emission from the Earth's atmosphere, which is time-dependent and highly nonlinear in frequency. Here, we present Time-dependent End-to-end Model for Post-process Optimization (TiEMPO) of the DEep Spectroscopic HIgh-redshift MApper (DESHIMA) spectrometer. TiEMPO utilizes a dynamical model of the atmosphere and parameterized models of the astronomical source, the telescope, the instrument, and the detector. The output of TiEMPO is a time stream of sky brightness temperature and detected power, which can be analyzed by standard signal-processing software. We first compare TiEMPO simulations with an on-sky measurement by the wideband DESHIMA spectrometer, and find good agreement in the noise and sensitivity. We then use TiEMPO to simulate the detection of the line emission spectrum of a high-redshift galaxy using the DESHIMA 2.0 spectrometer in development. The TiEMPO model is open source. Its modular and parametrized design enables users to adapt it to optimize the end-to-end performance of spectroscopic and photometric instruments on existing and future telescopes. © The Authors.Published by SPIE under a Creative Commons Attribution 4.0 International License. Distribution or reproduction of this work in whole or in part requires full attribution of the original publication, including its DOI.