Did I find the right examples for you? yes no

All Samples(14)  |  Call(14)  |  Derive(0)  |  Import(0)
Same as cpu_percent() but provides utilization percentages
for each specific CPU time as is returned by cpu_times().
For instance, on Linux we'll get:

  >>> cpu_times_percent()
  cpupercent(user=4.8, nice=0.0, system=4.8, idle=90.5, iowait=0.0,
             irq=0.0, softirq=0.0, steal=0.0, guest=0.0, guest_nice=0.0)
  >>>

interval and percpu arguments have the same meaning as in(more...)

        def cpu_times_percent(interval=None, percpu=False):
    """Same as cpu_percent() but provides utilization percentages
    for each specific CPU time as is returned by cpu_times().
    For instance, on Linux we'll get:

      >>> cpu_times_percent()
      cpupercent(user=4.8, nice=0.0, system=4.8, idle=90.5, iowait=0.0,
                 irq=0.0, softirq=0.0, steal=0.0, guest=0.0, guest_nice=0.0)
      >>>

    interval and percpu arguments have the same meaning as in
    cpu_percent().
    """
    global _last_cpu_times_2
    global _last_per_cpu_times_2
    blocking = interval is not None and interval > 0.0

    def calculate(t1, t2):
        nums = []
        all_delta = sum(t2) - sum(t1)
        for field in t1._fields:
            field_delta = getattr(t2, field) - getattr(t1, field)
            try:
                field_perc = (100 * field_delta) / all_delta
            except ZeroDivisionError:
                field_perc = 0.0
            field_perc = round(field_perc, 1)
            if _WINDOWS:
                # XXX
                # Work around:
                # https://code.google.com/p/psutil/issues/detail?id=392
                # CPU times are always supposed to increase over time
                # or at least remain the same and that's because time
                # cannot go backwards.
                # Surprisingly sometimes this might not be the case on
                # Windows where 'system' CPU time can be smaller
                # compared to the previous call, resulting in corrupted
                # percentages (< 0 or > 100).
                # I really don't know what to do about that except
                # forcing the value to 0 or 100.
                if field_perc > 100.0:
                    field_perc = 100.0
                elif field_perc < 0.0:
                    field_perc = 0.0
            nums.append(field_perc)
        return _psplatform.scputimes(*nums)

    # system-wide usage
    if not percpu:
        if blocking:
            t1 = cpu_times()
            time.sleep(interval)
        else:
            t1 = _last_cpu_times_2
        _last_cpu_times_2 = cpu_times()
        return calculate(t1, _last_cpu_times_2)
    # per-cpu usage
    else:
        ret = []
        if blocking:
            tot1 = cpu_times(percpu=True)
            time.sleep(interval)
        else:
            tot1 = _last_per_cpu_times_2
        _last_per_cpu_times_2 = cpu_times(percpu=True)
        for t1, t2 in zip(tot1, _last_per_cpu_times_2):
            ret.append(calculate(t1, t2))
        return ret
        


src/h/t/HTPC-Manager-HEAD/modules/stats.py   HTPC-Manager(Download)
    def cpu_percent(self):
        jcpu = None
        try:
            cpu = psutil.cpu_times_percent(interval=0.4, percpu=False)
            cpu = cpu._asdict()

src/t/t/ttop-0.7.2/ttop/core.py   ttop(Download)
    def update(self):
        times_percent = psutil.cpu_times_percent(percpu=True)
        cpu = psutil.cpu_times_percent()
        self.cpu.update(cpu.user, cpu.system, cpu.idle)
 

src/t/t/ttop-HEAD/ttop/core.py   ttop(Download)
    def update(self):
        times_percent = psutil.cpu_times_percent(percpu=True)
        cpu = psutil.cpu_times_percent()
        self.cpu.update(cpu.user, cpu.system, cpu.idle)
 

src/s/i/simocollector-1.2.3/simocollector/collectors.py   simocollector(Download)
    def get_cpu_utilization(self):
        _columns = ('user', 'nice', 'system', 'idle', 'iowait', 'irq', 'softirq', 'steal', 'quest', 'quest_nice')
        cpu_time_percent = psutil.cpu_times_percent(interval=3)
        data = dict(zip(_columns, cpu_time_percent))
        return data

src/p/s/psdash-0.3.0/psdash/web.py   psdash(Download)
        "swap": psutil.swap_memory(),
        "disks": disks,
        "cpu_percent": psutil.cpu_times_percent(0),
        "users": users,
        "net_interfaces": netifs,

src/p/s/psdash-HEAD/psdash/web.py   psdash(Download)
        "swap": psutil.swap_memory(),
        "disks": disks,
        "cpu_percent": psutil.cpu_times_percent(0),
        "users": users,
        "net_interfaces": netifs,

src/p/s/psutil-2.1.1/test/test_psutil.py   psutil(Download)
    def test_sys_cpu_times_percent(self):
        psutil.cpu_times_percent(interval=0.001)
        for x in range(1000):
            cpu = psutil.cpu_times_percent(interval=None)
            for percent in cpu:
                         psutil.cpu_count())
        for x in range(1000):
            cpus = psutil.cpu_times_percent(interval=None, percpu=True)
            for cpu in cpus:
                for percent in cpu:
        check(psutil.swap_memory())
        check(psutil.cpu_times())
        check(psutil.cpu_times_percent(interval=0))
        check(psutil.net_io_counters())
        check(psutil.disk_io_counters())

src/p/y/pyjip-0.5/jip/profiler.py   pyjip(Download)
        box_data = None
        if iostat and netstat:
            box_cpu = psutil.cpu_times_percent()
            io = psutil.disk_io_counters()
            netio = psutil.net_io_counters()

src/n/e/newRHELic-HEAD/newrelic.py   newRHELic(Download)
    def _get_cpu_states(self):
        '''This will get CPU states as a percentage of time'''
        try:
            cpu_states = psutil.cpu_times_percent()