We performed a series of 29 gasdynamical simulations of disc galaxies, barred and unbarred, with various stellar masses, to study the impact of the bar on star formation history. Unbarred galaxies evolve very smoothly, with a star formation rate (SFR) that varies by at most a factor of three over a period of 2 Gyr. The evolution of barred galaxies is much more irregular, especially at high stellar masses. In these galaxies, the bar drives a substantial amount of gas toward the centre, resulting in a high SFR, and producing a starburst in the most massive galaxies. Most of the gas is converted into stars, and gas exhaustion leads to a rapid drop of star formation after the starburst. In massive barred galaxies (stellar mass M * > 2 × 10 10 M ⊙ ) the large amount of gas funnelled toward the centre is completely consumed by the starburst, while in lower-mass barred galaxies it is only partially consumed. Gas concentration is thus higher in lower-mass barred galaxies than it is in higher-mass ones. Even though unbarred galaxies funnelled less gas toward their centre, the lower SFR allows this gas to accumulate. At late times, the star formation efficiency is higher in barred galaxies than unbarred ones, enabling these galaxies to maintain a higher SFR with a smaller gas supply. Several properties, such as the global SFR, central SFR, or central gas concentration, vary monotonically with time for unbarred galaxies, but not for barred galaxies. Therefore one must be careful when comparing barred and unbarred galaxies that share one observational property, since these galaxies might be at very different stages of their respective evolution.