Re: [Quickfix-developers] Details for Solaris / SunPRO 5.3 build
Brought to you by:
orenmnero
From: Caleb E. <cal...@gm...> - 2004-07-14 13:10:31
|
OK, here's an optimization to Field::calculate which improves the results from the "pt" application by a healthy amount. When possible, it uses a fixed-size char buffer and sprintf instead of building up a string with operator+. It falls back to the old behavior if the fixed buffer is too small. I also changed the checksum calculation to use std::accumulate, which probably has no real impact on anything other than lines-of-code. ---8<--- void calculate() { char buf[64]; // If the largest possible representation of the field ID (11 // digits) '=' value '\001' can fit in the buffer, use sprintf if (13 + m_string.length () < sizeof (buf)) { m_length = sprintf (buf, "%d=%*.*s\001", m_field, m_string.length (), m_string.length (), m_string.data ()); m_data.assign (buf, m_length); } else { m_data = IntConvertor::convert(m_field) + "=" + m_string + "\001"; m_length = m_data.length (); } const char* iter = m_data.data (); m_total = std::accumulate (iter, iter + m_length, 0); } ---8<--- Before the change: Converting integers to strings: num: 10000, seconds: 0.006, num_per_second: 1.66667e+06 Converting strings to integers: num: 10000, seconds: 0.001, num_per_second: 1e+07 Converting doubles to strings: num: 10000, seconds: 0.019, num_per_second: 526316 Converting strings to doubles: num: 10000, seconds: 0.028, num_per_second: 357143 Creating Heartbeat messages: num: 10000, seconds: 0.113, num_per_second: 88495.6 Serializing Heartbeat messages to strings: num: 10000, seconds: 0.155, num_per_second: 64516.1 Serializing Heartbeat messages from strings: num: 10000, seconds: 0.275, num_per_second: 36363.6 Creating NewOrderSingle messages: num: 10000, seconds: 0.415, num_per_second: 24096.4 Serializing NewOrderSingle messages to strings: num: 10000, seconds: 0.41, num_per_second: 24390.2 Serializing NewOrderSingle messages from strings: num: 10000, seconds: 0.585, num_per_second: 17094 Creating QuoteRequest messages: num: 10000, seconds: 4.83, num_per_second: 2070.39 Serializing QuoteRequest messages to strings: num: 10000, seconds: 0.646, num_per_second: 15479.9 Serializing QuoteRequest messages from strings: num: 10000, seconds: 4.386, num_per_second: 2279.98 Reading fields from QuoteRequest message: num: 10000, seconds: 1.374, num_per_second: 7278.02 Storing NewOrderSingle messages: num: 10000, seconds: 0.576, num_per_second: 17361.1 Validating NewOrderSingle messages with no data dictionary: num: 10000, seconds: 0.071, num_per_second: 140845 Validating NewOrderSingle messages with data dictionary: num: 10000, seconds: 0.23, num_per_second: 43478.3 After: Converting integers to strings: num: 10000, seconds: 0.007, num_per_second: 1.42857e+06 Converting strings to integers: num: 10000, seconds: 0.001, num_per_second: 1e+07 Converting doubles to strings: num: 10000, seconds: 0.02, num_per_second: 500000 Converting strings to doubles: num: 10000, seconds: 0.027, num_per_second: 370370 Creating Heartbeat messages: num: 10000, seconds: 0.08, num_per_second: 125000 Serializing Heartbeat messages to strings: num: 10000, seconds: 0.118, num_per_second: 84745.8 Serializing Heartbeat messages from strings: num: 10000, seconds: 0.159, num_per_second: 62893.1 Creating NewOrderSingle messages: num: 10000, seconds: 0.255, num_per_second: 39215.7 Serializing NewOrderSingle messages to strings: num: 10000, seconds: 0.251, num_per_second: 39840.6 Serializing NewOrderSingle messages from strings: num: 10000, seconds: 0.355, num_per_second: 28169 Creating QuoteRequest messages: num: 10000, seconds: 3.131, num_per_second: 3193.87 Serializing QuoteRequest messages to strings: num: 10000, seconds: 0.62, num_per_second: 16129 Serializing QuoteRequest messages from strings: num: 10000, seconds: 2.846, num_per_second: 3513.7 Reading fields from QuoteRequest message: num: 10000, seconds: 1.172, num_per_second: 8532.42 Storing NewOrderSingle messages: num: 10000, seconds: 0.633, num_per_second: 15797.8 Validating NewOrderSingle messages with no data dictionary: num: 10000, seconds: 0.042, num_per_second: 238095 Validating NewOrderSingle messages with data dictionary: num: 10000, seconds: 0.189, num_per_second: 52910.1 -- Caleb Epstein cal...@gm... |