With the advancement of the manufacturing industry, there is a growing need for high-speed five-axis machine tools that offer superior precision. Current research indicates that with the increase in the feed rate of machine tools, the influence of machine tool dynamic performance on precision becomes increasingly significant. In addition to the tracking performance of a single machine axis system, the servo dynamics matching degree (SDMD) between each machine axis system has also been widely recognized as one of the important factors affecting the dynamic performance in recent research. As an ISO standard specimen, the S-specimen has emerged as the frequently utilized specimens for machine tool acceptance testing, owing to its capacity to better reflect the dynamic performance of five-axis machine tools. Nevertheless, the intricate mapping relationship between the factors influencing SDMD and the contour error of the S-specimen constrains the applicability of this standard specimen in error diagnosis and subsequent dynamic performance optimization. Therefore, based on the machining process of the S-specimen, a dynamic performance optimization method by improving SDMD was proposed in this paper. An index of SDMD between two machine axis systems (two-axis SDMDI) was established which clarifies the specific source for error diagnosis. A calculation model of the two-axis SDMDIs of five-axis machine tool was established based on the mapping relationship between the index and the contour error of S-specimen which provided an effective way for optimization of SDMD based on S-specimen machining test. Experiments were carried out to verify the effectiveness of the proposed optimization method.