本文对Android设备CPU的状态查看方法和锁频(lock frequency)方法进行详细介绍。这有什么用?作为测试工程师,你值得了解。
首先说下CPU的频率。我们都知道,CPU的工作频率越高,运算就越快,但能耗也更高。然而很多时候,设备并不需要那么高的计算性能,这个时候,我们就希望能降低CPU的工作频率,追求较低的能耗,以此实现更长的待机时间。
基于此需求,当前电子设备的CPU都会存在多个工作频率,并能根据实际场景进行CPU频率的自动切换,以此达到平衡计算性能与能耗的目的。
import signal,functools #下面会用到的两个库 | |
class TimeoutError(Exception): pass #定义一个Exception,后面超时抛出 | |
def timeout(seconds, error_message = 'Function call timed out'): | |
def decorated(func): | |
def _handle_timeout(signum, frame): | |
raise TimeoutError(error_message) | |
def wrapper(*args, **kwargs): | |
signal.signal(signal.SIGALRM, _handle_timeout) | |
signal.alarm(seconds) |
// Use Gists to store code you would like to remember later on | |
console.log(window); // log the "window" object to the console |
Download the following files from Oracle
$VERSION
-macosx-x64.zip$VERSION
-macosx-x64.zipEdit ~/.zshrc
or ~/.bashrc
, add following:
http://geekgirl.io/concurrent-http-requests-with-python3-and-asyncio/
My friend who is a data scientist had wipped up a script that made lots (over 27K) of queries to the Google Places API. The problem was that it was synchronous and thus took over 2.5 hours to complete.
Given that I'm currently attending Hacker School and get to spend all day working on any coding problems that interests me, I decided to go about trying to optimise it.
I'm new to Python so had to do a bit of groundwork first to determine which course of action was best.
"""Comparison of fetching web pages sequentially vs. asynchronously | |
Requirements: Python 3.5+, Requests, aiohttp, cchardet | |
For a walkthrough see this blog post: | |
http://mahugh.com/2017/05/23/http-requests-asyncio-aiohttp-vs-requests/ | |
""" | |
import asyncio | |
from timeit import default_timer |