技术宅,fat-man

增加语言的了解程度可以避免写出愚蠢的代码

导航

2014年1月17日 #

一篇旧文章,结合汇编探索this指针

摘要: //VC6.0下成功编译#include class X{public: void foo(int b,int c){ this->a=b*c; cout 左 4)被调函数进行栈清理*///BCB6.0 下成功编译#include class X{public: void foo(int b,int c){ a = b*c; cout<<"a="<<a<<endl; } int a;};int main(){ X x; //04 void (X::*pXfoo)(int,int);... 阅读全文

posted @ 2014-01-17 18:19 codestyle 阅读(453) 评论(0) 推荐(0)

性能相差极大的SQL语句

摘要: 等价的SQL,性能差异极大,数据库里设计了一个字段存储日期时间,但不是datetime类型,用了时间戳(int 11), 下面有2个SQL语句用于查询数据库,一个是把时间戳转成date进行查询,一个是把日期转成时间戳,直接用时间戳进行比对,虽然没有统计差多少,但从直觉上发现至少能差10倍以上-- 性能较差的SQL,把数据库的时间戳转成datetime,用字符串比对select bid,price,platform from bc_user_charged_list_wap_merge where from_unixtime(charged_time) like '20140116%&# 阅读全文

posted @ 2014-01-17 15:00 codestyle 阅读(336) 评论(0) 推荐(0)

使用date命令,进行时间戳和日期时间的互转

摘要: 首先是知道时间转成时间戳date -d "2014-01-16 12:30:11" +%s date -d "2014-01-16" +%s # 等价于2014-01-16 00:00:00date -d "20140116" +%s # 等价于2014-01-16 00:00:00其次是知道时间戳,想要知道当时的时间date -d '1970-01-01 UTC 1389801600 seconds'# 1389801600 是2014-01-16 00:00:00 时对应的时间戳# 输出:Thu Jan 16 00 阅读全文

posted @ 2014-01-17 14:21 codestyle 阅读(440) 评论(0) 推荐(0)