Are there better conversion functions from ISO date format (calendar, ordinal, week dates) in basic and/or extended format? Should conversion from invalid iso date like "20050231" fail or produce same results as date(2005,02,31). (I know that it produces the same results, but is it right to convert invalid iso date representation to valid date?) Another thing I noted, some conversion functions accept const std::string &, but most of them accept plain std::string, isn't better to convert all of them to constant references??? If anybody interested, I wrote such function that accepts iso date string in any of the above mentioned 6 combinations and returns date. It runs 90-100 times faster than equivalent date_from_iso_string from boost. And yes, it does make sure that "20050229" fails
I too tested boost date and found that it is extremely slow and eventually had to write code that performs much faster. Speed is one of major strength of C++, we should produce performance details of each module as well. For example boost::variant is 20 times slower than boost::any, which are similar in functionality, boost::any is very easy to use and is very fast but does not support serialization. -----Original Message----- From: boost-users-bounces@lists.boost.org [mailto:boost-users-bounces@lists.boost.org] On Behalf Of __PPS__ Sent: Monday, October 24, 2005 2:18 AM To: boost-users@lists.boost.org Subject: [Boost-users] date_time: Are there better conversion functions from ISO date format (calendar, ordinal, week dates) in basic and/or extended format? Should conversion from invalid iso date like "20050231" fail or produce same results as date(2005,02,31). (I know that it produces the same results, but is it right to convert invalid iso date representation to valid date?) Another thing I noted, some conversion functions accept const std::string &, but most of them accept plain std::string, isn't better to convert all of them to constant references??? If anybody interested, I wrote such function that accepts iso date string in any of the above mentioned 6 combinations and returns date. It runs 90-100 times faster than equivalent date_from_iso_string from boost. And yes, it does make sure that "20050229" fails _______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
On Mon, 24 Oct 2005 07:08:49 -0400, Piyush Kapadia wrote
I too tested boost date and found that it is extremely slow and eventually had to write code that performs much faster.
For parsing only, or for other purposes? Your general statement isn't precise enough to be of help. Slowness in the parsing isn't a new report -- there are certainly a series of changes that would make the to_string routines faster. Some of them have been submitted over time and have been incorporated. Some that have been submitted incorporate statics and other techniques that might compromise the correctness of the library in some environments and hence don't get added. Submissions are always welcome.
Speed is one of major strength of C++, we should produce performance details of each module as well.
If you really want to help, perhaps you should consider becoming the Boost "performance wizard" -- it would be a tremendous amount of work.
For example boost::variant is 20 times slower than boost::any, which are similar in functionality, boost::any is very easy to use and is very fast but does not support serialization.
For what operation? There may be good reason why variant must be slower.
-----Original Message----- From: boost-users-bounces@lists.boost.org [mailto:boost-users-bounces@lists.boost.org] On Behalf Of __PPS__ Sent: Monday, October 24, 2005 2:18 AM To: boost-users@lists.boost.org Subject: [Boost-users] date_time:
Are there better conversion functions from ISO date format (calendar, ordinal, week dates) in basic and/or extended format? Should conversion from invalid iso date like "20050231" fail or produce same results as date(2005,02,31). (I know that it produces the same results, but is it right to convert invalid iso date representation to valid date?)
In 1.33 the following code produces 2 exceptions: try { std::string ds("20050231"); date d = from_undelimited_string(ds); std::cout << d << std::endl; } catch(bad_day_of_month& e) { std::cout << "exception: " << e.what() << std::endl; } try { date d(2005,02,31); std::cout << d << std::endl; } catch(bad_day_of_month& e) { std::cout << "exception: " << e.what() << std::endl; }
Another thing I noted, some conversion functions accept const std::string &, but most of them accept plain std::string, isn't better to convert all of them to constant references???
Sure unless they copy the string anyway, which I don't think they do.
If anybody interested, I wrote such function that accepts iso date string in any of the above mentioned 6 combinations and returns date. It runs 90-100 times faster than equivalent date_from_iso_string from boost. And yes, it does make sure that "20050229" fails
As I said above, contributions always welcome. Jeff
Jeff Garland wrote:
Are there better conversion functions from ISO date format (calendar, ordinal, week dates) in basic and/or extended format? Should conversion from invalid iso date like "20050231" fail or produce same results as date(2005,02,31). (I know that it produces the same results, but is it right to convert invalid iso date representation to valid date?)
In 1.33 the following code produces 2 exceptions:
try { std::string ds("20050231"); date d = from_undelimited_string(ds); std::cout << d << std::endl; } catch(bad_day_of_month& e) { std::cout << "exception: " << e.what() << std::endl; }
try { date d(2005,02,31); std::cout << d << std::endl; } catch(bad_day_of_month& e) { std::cout << "exception: " << e.what() << std::endl; }
Ok, I was wrong that they produce the same results, but I was wrong cause I didn't expect that date(2005,02,31) checks date correctness similar to from_undelimited_string("20050231"); which does not. Did you try to run these two examples? I got this output (v 1.33): 2005-Mar-03 exception: Day of month is not valid for year
Another thing I noted, some conversion functions accept const std::string &, but most of them accept plain std::string, isn't better to convert all of them to constant references???
Sure unless they copy the string anyway, which I don't think they do.
from_undelimited_string(std::string) does exactly the same as date_from_iso_string(const std::string &)
If anybody interested, I wrote such function that accepts iso date string in any of the above mentioned 6 combinations and returns date. It runs 90-100 times faster than equivalent date_from_iso_string from boost. And yes, it does make sure that "20050229" fails
As I said above, contributions always welcome.
this is my code that converts iso date string to gregorian::date: http://tinyurl.com/cvqhb Waiting for comments...
On Mon, 24 Oct 2005 12:51:20 -0400, __PPS__ wrote:
Jeff Garland wrote:
...snip...
Ok, I was wrong that they produce the same results, but I was wrong cause I didn't expect that date(2005,02,31) checks date correctness similar to from_undelimited_string("20050231"); which does not. Did you try to run these two examples? I got this output (v 1.33): 2005-Mar-03 exception: Day of month is not valid for year
Try it with a fresh cvs version. We've recently fixed a few bugs and I believe this was one of them.
Another thing I noted, some conversion functions accept const std::string &, but most of them accept plain std::string, isn't better to convert all of them to constant references???
Sure unless they copy the string anyway, which I don't think they do.
from_undelimited_string(std::string) does exactly the same as date_from_iso_string(const std::string &)
The date_from_iso_string function was written in Apr 2004 by myself. The from_undelimited_string was written in Aug 2002 by Jeff (I believe). Originally they strings were passed in by-value. The later function(s) were by-reference. The remaining discrepancy is nothing more that a lot of time between work done by two different people. Your point is noted and the task of reviewing by-value/by-reference will be put on the todo list. Bart
On Mon, 24 Oct 2005 17:00:07 -0700, Bart wrote
On Mon, 24 Oct 2005 12:51:20 -0400, __PPS__ wrote:
Jeff Garland wrote:
...snip...
Ok, I was wrong that they produce the same results, but I was wrong cause I didn't expect that date(2005,02,31) checks date correctness similar to from_undelimited_string("20050231"); which does not. Did you try to run these two examples? I got this output (v 1.33): 2005-Mar-03 exception: Day of month is not valid for year
Try it with a fresh cvs version. We've recently fixed a few bugs and I believe this was one of them.
Oops -- sorry bout that -- I actaully used the latest CVS not 1.33 to run my test -- so we must have fixed this post 1.33. I'll look over you more performant code, thx. Jeff
I will post test code for date & variant performance. -----Original Message----- From: boost-users-bounces@lists.boost.org [mailto:boost-users-bounces@lists.boost.org] On Behalf Of Jeff Garland Sent: Monday, October 24, 2005 8:35 AM To: boost-users@lists.boost.org Subject: Re: [Boost-users] date_time: On Mon, 24 Oct 2005 07:08:49 -0400, Piyush Kapadia wrote
I too tested boost date and found that it is extremely slow and eventually had to write code that performs much faster.
For parsing only, or for other purposes? Your general statement isn't precise enough to be of help. Slowness in the parsing isn't a new report -- there are certainly a series of changes that would make the to_string routines faster. Some of them have been submitted over time and have been incorporated. Some that have been submitted incorporate statics and other techniques that might compromise the correctness of the library in some environments and hence don't get added. Submissions are always welcome.
Speed is one of major strength of C++, we should produce performance details of each module as well.
If you really want to help, perhaps you should consider becoming the Boost "performance wizard" -- it would be a tremendous amount of work.
For example boost::variant is 20 times slower than boost::any, which are similar in functionality, boost::any is very easy to use and is very fast but does not support serialization.
For what operation? There may be good reason why variant must be slower.
-----Original Message----- From: boost-users-bounces@lists.boost.org [mailto:boost-users-bounces@lists.boost.org] On Behalf Of __PPS__ Sent: Monday, October 24, 2005 2:18 AM To: boost-users@lists.boost.org Subject: [Boost-users] date_time:
Are there better conversion functions from ISO date format (calendar, ordinal, week dates) in basic and/or extended format? Should conversion from invalid iso date like "20050231" fail or produce same results as date(2005,02,31). (I know that it produces the same results, but is it right to convert invalid iso date representation to valid date?)
In 1.33 the following code produces 2 exceptions: try { std::string ds("20050231"); date d = from_undelimited_string(ds); std::cout << d << std::endl; } catch(bad_day_of_month& e) { std::cout << "exception: " << e.what() << std::endl; } try { date d(2005,02,31); std::cout << d << std::endl; } catch(bad_day_of_month& e) { std::cout << "exception: " << e.what() << std::endl; }
Another thing I noted, some conversion functions accept const std::string &, but most of them accept plain std::string, isn't better to convert all of them to constant references???
Sure unless they copy the string anyway, which I don't think they do.
If anybody interested, I wrote such function that accepts iso date string in any of the above mentioned 6 combinations and returns date. It runs 90-100 times faster than equivalent date_from_iso_string from boost. And yes, it does make sure that "20050229" fails
As I said above, contributions always welcome. Jeff _______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
participants (4)
-
__PPS__
-
Bart
-
Jeff Garland
-
Piyush Kapadia