1 /** @file randomize_serials.cpp
3 * Utility function used by the benchmarks.
7 * GiNaC Copyright (C) 1999-2024 Johannes Gutenberg University Mainz, Germany
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
25 using namespace GiNaC;
31 /** Generate a random amount of symbols and destroy them again immediately.
32 * This operation effectively makes the serial numbers of all subsequent
33 * symbols unpredictable. If the serials are unpredictable, then so are
34 * their hash values. If the hash values are unpredictable, then so are
35 * the canonical orderings. If the canonical orderings are unpredictable,
36 * all subsequent times are subject to some variation. This variation,
37 * however is natural and desirable for two reasons: First, we cannot know
38 * how many symbols have been generated before in real world computations.
39 * Second, the following timings are subject to some semi-random variation
40 * anyways because short timings need to be repeated until enough time has
41 * gone by for the measurement to be reliable. During this process the serial
42 * numbers will be shifted anyways in a semi-random way. It is better not
43 * to lull the user in a false sense of reproducibility and instead confront
44 * her with the normal variation to be expected.
46 void randomify_symbol_serials()
49 const int m = rand() % 666;
50 for (int s=0; s<m; ++s ) {