Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Pedro Alves <palves@redhat.com>
To: Simon Marchi <simon.marchi@polymtl.ca>
Cc: gdb-patches@sourceware.org
Subject: Re: [PATCH v2] gdb: Use C++11 std::chrono
Date: Wed, 23 Nov 2016 02:17:00 -0000	[thread overview]
Message-ID: <4dc8d860-16f0-65cc-796c-da240d8ffd9f@redhat.com> (raw)
In-Reply-To: <a5f358b4756a84465482f27040bac553@polymtl.ca>

On 11/23/2016 02:01 AM, Simon Marchi wrote:

> From what I understand, {user,system}_cpu_time_clock are only defined in
> order to be able to use their time_point type?  It feels a bit
> overengineered, unless you expect those types to differ at some point. 
> Is there an advantage of having different types over having a single
> clock type and this
> 
>   run_time_clock::now (run_time_clock::time_point &user,
> run_time_clock::time_point &system)
> 
> ?

I kept them (from v1) for type-safety: it makes it impossible to swap
the arguments to this new now() method by mistake, or compare old
system time with new user time by mistake.  E.g.:

/usr/include/c++/5.3.1/chrono:650:7: note: candidate: template<class _Clock, class _Dur1, class _Dur2> constexpr typename std::common_type<_Duration1, _Duration2>::type std::chrono::operator-(const std::chrono::time_point<_Clock, _Duration1>&, const std::chrono::time_point<_Clock, _Duration2>&)
       operator-(const time_point<_Clock, _Dur1>& __lhs,
       ^
/usr/include/c++/5.3.1/chrono:650:7: note:   template argument deduction/substitution failed:
src/gdb/mi/mi-main.c:2493:48: note:   deduced conflicting types for parameter ‘_Clock’ (‘system_cpu_time_clock’ and ‘user_cpu_time_clock’)
   duration<double> utime = end->stime - start->utime;
                                                ^

Would you still prefer I remove those?

> Unrelated: for future work, it looks like an std::priority_queue would
> be a nice match for timer_list.

Maybe, but we'd need to inherit from it in order to be able to
delete timers that are not at the top of the heap.  A set or
multiset would be other options.

Thanks,
Pedro Alves


  reply	other threads:[~2016-11-23  2:17 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-11-17 17:15 [PATCH] " Pedro Alves
2016-11-17 22:15 ` Simon Marchi
2016-11-23  0:59   ` [PATCH v2] " Pedro Alves
2016-11-23  2:01     ` Simon Marchi
2016-11-23  2:17       ` Pedro Alves [this message]
2016-11-23  2:27         ` Simon Marchi
2016-11-23  2:36           ` Pedro Alves
2016-11-23  2:57             ` Simon Marchi
2016-11-23 14:48               ` Simon Marchi
2016-11-23 16:02                 ` Pedro Alves
2016-11-23 16:11                   ` Simon Marchi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4dc8d860-16f0-65cc-796c-da240d8ffd9f@redhat.com \
    --to=palves@redhat.com \
    --cc=gdb-patches@sourceware.org \
    --cc=simon.marchi@polymtl.ca \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox