What is wrong with this measurement of the synodic period of Mercury?
Mercury's orbit is highly eccentric: 0.21 according to Wikipedia. Therefore, the actual time between repeating occurrences will vary depending on the year. If you were to perform your calculations for many periods, the average should approach the value given by Stellarium.

The theoretical synodic period, using the sidereal period of Earth and Mercury, is 115.9 days.