Esempio n. 1
0
    def __init__(self):

        self.python_version = platform.python_version()

        self.os = self._get_os()
        self.node = platform.node()
        self.distribution = " ".join(platform.dist())
        self.machine = platform.machine()
        self.architecture = platform.architecture()[0]

        # CPU
        self.cpu = self._get_cpu()
        self.number_of_cores = self._get_number_of_cores()
        self.cpu_khz = self._get_cpu_khz()
        self.cpu_mhz = rint(self._get_cpu_khz() / float(1000))

        # RAM
        self.memory_size_kb = self._get_memory_size_kb()
        self.memory_size_mb = rint(self.memory_size_kb / float(1024))
Esempio n. 2
0
    def __str__(self):

        string_template = """LRU cache:
  size =  %u / %u = %u %%
  from the younger to the older
"""
        text = string_template % (self._size, self._constraint,
                                  rint(inverse_percent(self._size / float(self._constraint))))

        string_template = '  [%4u] key=%s rc=%u size=%u obj=%s\n'
        i = 0
        for cache_element in self:
            text += string_template % (i,
                                       str(cache_element.key),
                                       cache_element._reference_counter,
                                       cache_element._size_in_cache,
                                       str(cache_element._obj))
            i += 1

        return text
Esempio n. 3
0
    def closest_level(self, resolution):

        return rint(math.log(self._root_resolution / resolution) / math.log(2))