滴滴测开一二面面筋
1.列举15个常用的linux指令,并解释用法
软链接和硬链接
2.统计一个ip记录文件中的top5 ip
3.数据库两个表的联查
4.实现一个函数:把表示整形的字符串转化为整形
不可以使用int强制转换函数
5.在一个字符串中,找到第一个只出现一次的字符,比如字符串是ccdeeefabb,则该字符是d
二面
已知服务A的请求方法为:
int requestA(Request &req,int timeout, int &timecost){
// timeout: 超时时间 单位ms
// timecost: 本次请求耗时
return errno;// 成功0,失败1
}
设计一个简单压测工具,支持并发请求A一段时间,并统计全部请求成功数、失败数、平均响应时间和XX(1~99)分位耗时阈值。
说明:
1、假设请求设置的超时时间是1000ms,如果发生超时,认为请求失败
2、XX分位耗时阈值:XX%的请求处理时间耗时在多长时间以内,精度到ms。
3、假设总请求总数少于32亿
以下线程池实现可以直接使用,也可以自己的方式实现并发。
class ThreadPool {
ThreadPool(int threadnum){}
std::list<std::function<void(void)>> queue;
/**
* Add a new job to the pool. If there are no jobs in the queue,
* a thread is woken up to take the job. If all threads are busy,
* the job is added to the end of the queue.
*/
void AddJob( std::function<void(void)> job ) {}
/**
* Join with all threads.
*/
void JoinAll( bool WaitForAll = true ) {}
};