// 测试mktime和localtime_r性能及优化方法
//
// 编译方法:g++ -g -o x x.cpp或g++ -O2 -o x x.cpp,两种编译方式性能基本相同。
//
// 结论:
// 1) 环境变量TZ和isdst均不影响localtime_r的性能(第一次调用了除外)
// 2) 环境变量TZ严重影响localtime的性能
// 3) 环境变量TZ和isdst均会严重影响mktime的性能
// *4) 注意mktime的参数即是输入参数也是输出参数,它会修改isdst值
// *5) 另外需要注意localtime_r为非信号安全函数,
// 不能在信号处理过程中调用,否则可能发生死锁等问题
//
// 64位机器性能数据(与32位CPU不同):
/*
$ ./x 1000000
test: localtime ...
TZ is NULL: 2457ms
TZ is empty: 172ms
TZ is Asia/Shanghai: 173ms test: localtime_r ...
TZ is NULL and isdst=1: 125ms
TZ is NULL and isdst=0: 125ms
TZ is NULL and isdst=-1: 125ms
TZ is NULL and isdst undefined: 125ms
TZ is empty and isdst=1: 125ms
TZ is empty and isdst=0: 125ms
TZ is empty and isdst=-1: 125ms
TZ is empty and isdst undefined: 127ms
TZ is Asia/Shanghai and isdst=1: 126ms
TZ is Asia/Shanghai and isdst=0: 125ms
TZ is Asia/Shanghai and isdst=-1: 125ms
TZ is Asia/Shanghai and isdst undefined: 125ms test: mktime ...
TZ is NULL and isdst=1: 635841ms
TZ is NULL and isdst=0: 2583ms
TZ is NULL and isdst=-1: 2596ms
TZ is NULL and isdst undefined: 2579ms
TZ is empty and isdst=1: 122377ms
TZ is empty and isdst=0: 229ms
TZ is empty and isdst=-1: 230ms
TZ is empty and isdst undefined: 229ms
TZ is Asia/Shanghai and isdst=1: 122536ms
TZ is Asia/Shanghai and isdst=0: 228ms
TZ is Asia/Shanghai and isdst=-1: 230ms
TZ is Asia/Shanghai and isdst undefined: 228ms
*/ // 32位机器性能数据(与64位CPU不同):
/*
$ ./x 1000000
test: localtime ...
TZ is NULL: 1445ms
TZ is empty: 252ms
TZ is Asia/Shanghai: 252ms test: localtime_r ...
TZ is NULL and isdst=1: 161ms
TZ is NULL and isdst=0: 160ms
TZ is NULL and isdst=-1: 161ms
TZ is NULL and isdst undefined: 161ms
TZ is empty and isdst=1: 160ms
TZ is empty and isdst=0: 161ms
TZ is empty and isdst=-1: 161ms
TZ is empty and isdst undefined: 161ms
TZ is Asia/Shanghai and isdst=1: 161ms
TZ is Asia/Shanghai and isdst=0: 161ms
TZ is Asia/Shanghai and isdst=-1: 161ms
TZ is Asia/Shanghai and isdst undefined: 161ms test: mktime ...
TZ is NULL and isdst=1: 199375ms
TZ is NULL and isdst=0: 1488ms
TZ is NULL and isdst=-1: 1483ms
TZ is NULL and isdst undefined: 1497ms
TZ is empty and isdst=1: 161057ms
TZ is empty and isdst=0: 325ms
TZ is empty and isdst=-1: 328ms
TZ is empty and isdst undefined: 326ms
TZ is Asia/Shanghai and isdst=1: 161558ms
TZ is Asia/Shanghai and isdst=0: 321ms
TZ is Asia/Shanghai and isdst=-1: 335ms
TZ is Asia/Shanghai and isdst undefined: 328ms
*/
// localtime_r相关源代码:
/*
// The C Standard says that localtime and gmtime return the same pointer.
struct tm _tmbuf; // 全局变量 struct tm * __localtime_r (t, tp)
const time_t *t;
struct tm *tp;
{
return __tz_convert (t, 1, tp);
} // 非线程安全版本,用到了全局变量_tmbuf
struct tm * localtime(t)
const time_t *t;
{
return __tz_convert (t, 1, &_tmbuf);
} struct tm * __tz_convert (const time_t *timer, int use_localtime, struct tm *tp)
{
。。。
// 信号处理函数中调用非信号安全函数,可能造成死锁的地方
__libc_lock_lock (tzset_lock); // localtime_r未用到_tmbuf,只是localtime使用它!!!
// 因此对于localtime_r,传递给tzset_internal的第一个参数总是为0(tp != &_tmpbuf),
// 而对于localtime,它传递给tzset_internal的第一个参数总是为1
tzset_internal (tp == &_tmbuf && use_localtime, 1);
。。。
} // 决定性能的函数,原因是可能涉及文件操作,
// 因此要想提升性能,则应当想办法避免操作文件!!!
static void internal_function
tzset_internal (always, explicit)
int always;
int explicit;
{
static int is_initialized; // 静态变量
const char *tz; // 对于mktime,参数always值总是为1
// 对于localtime,参数always值总是为1
// 对于localtime_r,参数always值总是为0
if (is_initialized && !always)
return; // 对于localtime_r第一次调用后,后续都在这里直接返回!
is_initialized = 1; tz = getenv ("TZ");
if (tz == NULL && !explicit)
tz = TZDEFAULT;
if (tz && *tz == '\0')
tz = "Universal";
if (tz && *tz == ':')
++tz; // 如果不设置环境变量TZ,则下面这个if语句总是不成立!!!
// 因此只有设置了环境变量TZ,才有可能在这里直接返回而不进入读文件操作__tzfile_read
if (old_tz != NULL && tz != NULL && strcmp (tz, old_tz) == 0)
return; // 在这里返回则可以避免走到文件操作__tzfile_read
if (tz == NULL)
tz = TZDEFAULT; tz_rules[0].name = NULL;
tz_rules[1].name = NULL; // Save the value of `tz'.
free (old_tz);
old_tz = tz ? __strdup (tz) : NULL; // 读文件,性能慢的原因
__tzfile_read (tz, 0, NULL); // Try to read a data file.
if (__use_tzfile)
return;
。。。
}
*/
// mktime相关源代码:
/*
time_t mktime (struct tm *tp)
{
#ifdef _LIBC
// POSIX.1 8.1.1 requires that whenever mktime() is called, the
// time zone names contained in the external variable 'tzname' shall
// be set as if the tzset() function had been called.
__tzset ();
#endif // __mktime_internal会调用localtime_r,
// isdst的取值在这里会严重影响到mktime的性能
return __mktime_internal (tp, __localtime_r, &localtime_offset);
} void __tzset (void)
{
__libc_lock_lock (tzset_lock); // 和localtime_r一样也会调用tzset_internal
tzset_internal (1, 1); if (!__use_tzfile)
{
// Set `tzname'.
__tzname[0] = (char *) tz_rules[0].name;
__tzname[1] = (char *) tz_rules[1].name;
} __libc_lock_unlock (tzset_lock);
}
*/
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <sys/time.h>
#include <time.h> static void test_localtime(int M); // 测试localtime性能
static void test_localtime_r(int M); // 测试localtime_r性能
static void test_mktime(int M); // 测试mktime性能 int main(int argc, char* argv[])
{
const int M = (argc<2)? 1000000: atoi(argv[1]); test_localtime(M);
printf("\n");
test_localtime_r(M);
printf("\n");
test_mktime(M); return 0;
} // test_localtime
void test_localtime(int M)
{
int i;
time_t now = time(NULL);
struct timeval tv1, tv2; printf("test: localtime ...\n");
unsetenv("TZ"); // test1
{
struct tm* result1;
gettimeofday(&tv1, NULL);
for (i=0; i<M; ++i)
{
result1 = localtime(&now);
}
gettimeofday(&tv2, NULL);
printf("TZ is NULL: %ums\n", (tv2.tv_sec-tv1.tv_sec)*1000 + (tv2.tv_usec-tv1.tv_usec)/1000);
} setenv("TZ", "", 0); // test2
{
struct tm* result2;
gettimeofday(&tv1, NULL);
for (i=0; i<M; ++i)
{
result2 = localtime(&now);
}
gettimeofday(&tv2, NULL);
printf("TZ is empty: %ums\n", (tv2.tv_sec-tv1.tv_sec)*1000 + (tv2.tv_usec-tv1.tv_usec)/1000);
} setenv("TZ", "Asia/Shanghai", 0); // test3
{
struct tm* result3;
gettimeofday(&tv1, NULL);
for (i=0; i<M; ++i)
{
result3 = localtime(&now);
}
gettimeofday(&tv2, NULL);
printf("TZ is Asia/Shanghai: %ums\n", (tv2.tv_sec-tv1.tv_sec)*1000 + (tv2.tv_usec-tv1.tv_usec)/1000);
}
} // test_localtime_r
void test_localtime_r(int M)
{
int i;
time_t now = time(NULL);
struct timeval tv1, tv2; printf("test: localtime_r ...\n");
unsetenv("TZ"); // test1
{
struct tm result1;
gettimeofday(&tv1, NULL);
for (i=0; i<M; ++i)
{
struct tm result1_;
memcpy(&result1_, &result1, sizeof(result1_));
result1_.tm_isdst = 1;
localtime_r(&now, &result1_);
}
gettimeofday(&tv2, NULL);
printf("TZ is NULL and isdst=1: %ums\n", (tv2.tv_sec-tv1.tv_sec)*1000 + (tv2.tv_usec-tv1.tv_usec)/1000);
} // test2
{
struct tm result2;
gettimeofday(&tv1, NULL);
for (i=0; i<M; ++i)
{
struct tm result2_;
memcpy(&result2_, &result2, sizeof(result2_));
result2_.tm_isdst = 0;
localtime_r(&now, &result2_);
}
gettimeofday(&tv2, NULL);
printf("TZ is NULL and isdst=0: %ums\n", (tv2.tv_sec-tv1.tv_sec)*1000 + (tv2.tv_usec-tv1.tv_usec)/1000);
} // test3
{
struct tm result3;
gettimeofday(&tv1, NULL);
for (i=0; i<M; ++i)
{
struct tm result3_;
memcpy(&result3_, &result3, sizeof(result3_));
result3_.tm_isdst = -1;
localtime_r(&now, &result3_);
}
gettimeofday(&tv2, NULL);
printf("TZ is NULL and isdst=-1: %ums\n", (tv2.tv_sec-tv1.tv_sec)*1000 + (tv2.tv_usec-tv1.tv_usec)/1000);
} // test4
{
struct tm result4;
gettimeofday(&tv1, NULL);
for (i=0; i<M; ++i)
{
struct tm result4_;
memcpy(&result4_, &result4, sizeof(result4_));
localtime_r(&now, &result4_);
}
gettimeofday(&tv2, NULL);
printf("TZ is NULL and isdst undefined: %ums\n", (tv2.tv_sec-tv1.tv_sec)*1000 + (tv2.tv_usec-tv1.tv_usec)/1000);
} setenv("TZ", "", 0); // test5
{
struct tm result5;
gettimeofday(&tv1, NULL);
for (i=0; i<M; ++i)
{
struct tm result5_;
memcpy(&result5_, &result5, sizeof(result5_));
result5_.tm_isdst = 1;
localtime_r(&now, &result5_);
}
gettimeofday(&tv2, NULL);
printf("TZ is empty and isdst=1: %ums\n", (tv2.tv_sec-tv1.tv_sec)*1000 + (tv2.tv_usec-tv1.tv_usec)/1000);
} // test6
{
struct tm result6;
gettimeofday(&tv1, NULL);
for (i=0; i<M; ++i)
{
struct tm result6_;
memcpy(&result6_, &result6, sizeof(result6_));
result6_.tm_isdst = 0;
localtime_r(&now, &result6_);
}
gettimeofday(&tv2, NULL);
printf("TZ is empty and isdst=0: %ums\n", (tv2.tv_sec-tv1.tv_sec)*1000 + (tv2.tv_usec-tv1.tv_usec)/1000);
} // test7
{
struct tm result7;
gettimeofday(&tv1, NULL);
for (i=0; i<M; ++i)
{
struct tm result7_;
memcpy(&result7_, &result7, sizeof(result7_));
result7_.tm_isdst = -1;
localtime_r(&now, &result7_);
}
gettimeofday(&tv2, NULL);
printf("TZ is empty and isdst=-1: %ums\n", (tv2.tv_sec-tv1.tv_sec)*1000 + (tv2.tv_usec-tv1.tv_usec)/1000);
} // test8
{
struct tm result8;
gettimeofday(&tv1, NULL);
for (i=0; i<M; ++i)
{
struct tm result8_;
memcpy(&result8_, &result8, sizeof(result8_));
result8_.tm_isdst = -1;
localtime_r(&now, &result8_);
}
gettimeofday(&tv2, NULL);
printf("TZ is empty and isdst undefined: %ums\n", (tv2.tv_sec-tv1.tv_sec)*1000 + (tv2.tv_usec-tv1.tv_usec)/1000);
} setenv("TZ", "Asia/Shanghai", 0); // test9
{
struct tm result9;
gettimeofday(&tv1, NULL);
for (i=0; i<M; ++i)
{
struct tm result9_;
memcpy(&result9_, &result9, sizeof(result9_));
result9_.tm_isdst = 1;
localtime_r(&now, &result9_);
}
gettimeofday(&tv2, NULL);
printf("TZ is Asia/Shanghai and isdst=1: %ums\n", (tv2.tv_sec-tv1.tv_sec)*1000 + (tv2.tv_usec-tv1.tv_usec)/1000);
} // test10
{
struct tm result10;
gettimeofday(&tv1, NULL);
for (i=0; i<M; ++i)
{
struct tm result10_;
memcpy(&result10_, &result10, sizeof(result10_));
result10_.tm_isdst = 0;
localtime_r(&now, &result10_);
}
gettimeofday(&tv2, NULL);
printf("TZ is Asia/Shanghai and isdst=0: %ums\n", (tv2.tv_sec-tv1.tv_sec)*1000 + (tv2.tv_usec-tv1.tv_usec)/1000);
} // test11
{
struct tm result11;
gettimeofday(&tv1, NULL);
for (i=0; i<M; ++i)
{
struct tm result11_;
memcpy(&result11_, &result11, sizeof(result11_));
result11_.tm_isdst = -1;
localtime_r(&now, &result11_);
}
gettimeofday(&tv2, NULL);
printf("TZ is Asia/Shanghai and isdst=-1: %ums\n", (tv2.tv_sec-tv1.tv_sec)*1000 + (tv2.tv_usec-tv1.tv_usec)/1000);
} // test12
{
struct tm result12;
gettimeofday(&tv1, NULL);
for (i=0; i<M; ++i)
{
struct tm result12_;
memcpy(&result12_, &result12, sizeof(result12_));
localtime_r(&now, &result12_);
}
gettimeofday(&tv2, NULL);
printf("TZ is Asia/Shanghai and isdst undefined: %ums\n", (tv2.tv_sec-tv1.tv_sec)*1000 + (tv2.tv_usec-tv1.tv_usec)/1000);
}
} // test_mktime
void test_mktime(int M)
{
int i;
time_t now = time(NULL);
struct timeval tv1, tv2; printf("test: mktime ...\n");
unsetenv("TZ"); // test1
{
struct tm result1;
localtime_r(&now, &result1);
gettimeofday(&tv1, NULL);
for (i=0; i<M; ++i)
{
struct tm result1_;
memcpy(&result1_, &result1, sizeof(result1_));
result1_.tm_isdst = 1;
mktime(&result1_);
}
gettimeofday(&tv2, NULL);
printf("TZ is NULL and isdst=1: %ums\n", (tv2.tv_sec-tv1.tv_sec)*1000 + (tv2.tv_usec-tv1.tv_usec)/1000);
} // test2
{
struct tm result2;
localtime_r(&now, &result2);
gettimeofday(&tv1, NULL);
for (i=0; i<M; ++i)
{
struct tm result2_;
memcpy(&result2_, &result2, sizeof(result2_));
result2_.tm_isdst = 0;
mktime(&result2_);
}
gettimeofday(&tv2, NULL);
printf("TZ is NULL and isdst=0: %ums\n", (tv2.tv_sec-tv1.tv_sec)*1000 + (tv2.tv_usec-tv1.tv_usec)/1000);
} // test3
{
struct tm result3;
localtime_r(&now, &result3);
gettimeofday(&tv1, NULL);
for (i=0; i<M; ++i)
{
struct tm result3_;
memcpy(&result3_, &result3, sizeof(result3_));
result3_.tm_isdst = -1;
mktime(&result3_);
}
gettimeofday(&tv2, NULL);
printf("TZ is NULL and isdst=-1: %ums\n", (tv2.tv_sec-tv1.tv_sec)*1000 + (tv2.tv_usec-tv1.tv_usec)/1000);
} // test4
{
struct tm result4;
localtime_r(&now, &result4);
gettimeofday(&tv1, NULL);
for (i=0; i<M; ++i)
{
struct tm result4_;
memcpy(&result4_, &result4, sizeof(result4_));
mktime(&result4_);
}
gettimeofday(&tv2, NULL);
printf("TZ is NULL and isdst undefined: %ums\n", (tv2.tv_sec-tv1.tv_sec)*1000 + (tv2.tv_usec-tv1.tv_usec)/1000);
} setenv("TZ", "", 0); // test5
{
struct tm result5;
localtime_r(&now, &result5);
gettimeofday(&tv1, NULL);
for (i=0; i<M; ++i)
{
struct tm result5_;
memcpy(&result5_, &result5, sizeof(result5_));
result5_.tm_isdst = 1;
mktime(&result5_);
}
gettimeofday(&tv2, NULL);
printf("TZ is empty and isdst=1: %ums\n", (tv2.tv_sec-tv1.tv_sec)*1000 + (tv2.tv_usec-tv1.tv_usec)/1000);
} // test6
{
struct tm result6;
localtime_r(&now, &result6);
gettimeofday(&tv1, NULL);
for (i=0; i<M; ++i)
{
struct tm result6_;
memcpy(&result6_, &result6, sizeof(result6_));
result6_.tm_isdst = 0;
mktime(&result6_);
}
gettimeofday(&tv2, NULL);
printf("TZ is empty and isdst=0: %ums\n", (tv2.tv_sec-tv1.tv_sec)*1000 + (tv2.tv_usec-tv1.tv_usec)/1000);
} // test7
{
struct tm result7;
localtime_r(&now, &result7);
gettimeofday(&tv1, NULL);
for (i=0; i<M; ++i)
{
struct tm result7_;
memcpy(&result7_, &result7, sizeof(result7_));
result7_.tm_isdst = -1;
mktime(&result7_);
}
gettimeofday(&tv2, NULL);
printf("TZ is empty and isdst=-1: %ums\n", (tv2.tv_sec-tv1.tv_sec)*1000 + (tv2.tv_usec-tv1.tv_usec)/1000);
} // test8
{
struct tm result8;
localtime_r(&now, &result8);
gettimeofday(&tv1, NULL);
for (i=0; i<M; ++i)
{
struct tm result8_;
memcpy(&result8_, &result8, sizeof(result8_));
mktime(&result8_);
}
gettimeofday(&tv2, NULL);
printf("TZ is empty and isdst undefined: %ums\n", (tv2.tv_sec-tv1.tv_sec)*1000 + (tv2.tv_usec-tv1.tv_usec)/1000);
} setenv("TZ", "Asia/Shanghai", 0); // test9
{
struct tm result9;
localtime_r(&now, &result9);
gettimeofday(&tv1, NULL);
for (i=0; i<M; ++i)
{
struct tm result9_;
memcpy(&result9_, &result9, sizeof(result9_));
result9_.tm_isdst = 1;
mktime(&result9_);
}
gettimeofday(&tv2, NULL);
printf("TZ is Asia/Shanghai and isdst=1: %ums\n", (tv2.tv_sec-tv1.tv_sec)*1000 + (tv2.tv_usec-tv1.tv_usec)/1000);
} // test10
{
struct tm result10;
localtime_r(&now, &result10);
gettimeofday(&tv1, NULL);
for (i=0; i<M; ++i)
{
struct tm result10_;
memcpy(&result10_, &result10, sizeof(result10_));
result10_.tm_isdst = 0;
mktime(&result10_);
}
gettimeofday(&tv2, NULL);
printf("TZ is Asia/Shanghai and isdst=0: %ums\n", (tv2.tv_sec-tv1.tv_sec)*1000 + (tv2.tv_usec-tv1.tv_usec)/1000);
} // test11
{
struct tm result11;
localtime_r(&now, &result11);
gettimeofday(&tv1, NULL);
for (i=0; i<M; ++i)
{
struct tm result11_;
memcpy(&result11_, &result11, sizeof(result11_));
result11_.tm_isdst = -1;
mktime(&result11_);
}
gettimeofday(&tv2, NULL);
printf("TZ is Asia/Shanghai and isdst=-1: %ums\n", (tv2.tv_sec-tv1.tv_sec)*1000 + (tv2.tv_usec-tv1.tv_usec)/1000);
} // test12
{
struct tm result12;
localtime_r(&now, &result12);
gettimeofday(&tv1, NULL);
for (i=0; i<M; ++i)
{
struct tm result12_;
memcpy(&result12_, &result12, sizeof(result12_));
mktime(&result12_);
}
gettimeofday(&tv2, NULL);
printf("TZ is Asia/Shanghai and isdst undefined: %ums\n", (tv2.tv_sec-tv1.tv_sec)*1000 + (tv2.tv_usec-tv1.tv_usec)/1000);
}
}

测试mktime和localtime_r性能及优化方法的更多相关文章

  1. 26种提高ASP.NET网站访问性能的优化方法 .

    1. 数据库访问性能优化 数据库的连接和关闭 访问数据库资源需要创建连接.打开连接和关闭连接几个操作.这些过程需要多次与数据库交换信息以通过身份验证,比较耗费服务器资源. ASP.NET中提供了连接池 ...

  2. DevExpress ChartControl大数据加载时有哪些性能优化方法

    DevExpress ChartControl加载大数据量数据时的性能优化方法有哪些? 关于图表优化,可从以下几个方面解决: 1.关闭不需要的可视化的元素(如LineMarkers, Labels等) ...

  3. Android性能优化方法(八)

    Android SDK tools目录下提供一个观察布局的工具,层级观察器(Hierarchy Viewer).Hierarchy Viewer工具是一个非常好的布局优化工具,同时,你也可以通过它学习 ...

  4. HBase性能优化方法总结(转)

    本文主要是从HBase应用程序设计与开发的角度,总结几种常用的性能优化方法.有关HBase系统配置级别的优化,这里涉及的不多,这部分可以参考:淘宝Ken Wu同学的博客. 1. 表的设计 1.1 Pr ...

  5. (摘录)26个ASP.NET常用性能优化方法

    数据库访问性能优化 数据库的连接和关闭 访问数据库资源需要创建连接.打开连接和关闭连接几个操作.这些过程需要多次与数据库交换信息以通过身份验证,比较耗费服务器资源. ASP.NET中提供了连接池(Co ...

  6. HBase性能优化方法总结(一):表的设计

    本文主要是从HBase应用程序设计与开发的角度,总结几种常用的性能优化方法.有关HBase系统配置级别的优化,可参考:淘宝Ken Wu同学的博客. 下面是本文总结的第一部分内容:表的设计相关的优化方法 ...

  7. 26个ASP.NET常用性能优化方法

    数据库访问性能优化 数据库的连接和关闭 访问数据库资源需要创建连接.打开连接和关闭连接几个操作.这些过程需要多次与数据库交换信息以通过身份验证,比较耗费服务器资源. ASP.NET中提供了连接池(Co ...

  8. redmine在linux上的mysql性能优化方法与问题排查方案

    iredmine的linux服务器mysql性能优化方法与问题排查方案     问题定位:   客户端工具: 1. 浏览器inspect-tool的network timing工具分析   2. 浏览 ...

  9. MySQL查询语句执行过程及性能优化-查询过程及优化方法(JOIN/ORDER BY)

    在上一篇文章MySQL查询语句执行过程及性能优化-基本概念和EXPLAIN语句简介中介绍了EXPLAIN语句,并举了一个慢查询例子:

随机推荐

  1. frame标签使用

    今天在做onebyone作业的时候,为了使自己的页面更加美观,我便使用了frame框架,百度了他的用法,总结如下 frame,是网页开发必须掌握的知识.例如后台架构.局部刷新,页面分割,都是frame ...

  2. 发布MVC项目到服务器上时候遇到的 模块 DirectoryListingModule 通知 ExecuteRequestHandler 处理程序 StaticFile 错误代码 0x00000000

    应用程序“HMW121197”中的服务器错误错误摘要HTTP 错误 403.14 - ForbiddenWeb 服务器被配置为不列出此目录的内容. 详细错误信息模块 DirectoryListingM ...

  3. 吴裕雄 数据挖掘与分析案例实战(2)——python数据结构及方法、控制流、字符串处理、自定义函数

    list1 = ['张三','男',33,'江苏','硕士','已婚',['身高178','体重72']]# 取出第一个元素print(list1[0])# 取出第四个元素print(list1[3] ...

  4. 大型运输行业实战_day09_2_站间互售实现

    1.添加站间互售入口 对应的html代码 <button onclick="otherStation()">站间互售</button> 对应的js发送函数 ...

  5. 安装RabbitMq-----windows

    在官网download我们所需要的版本,安装rabbitMq需要erlang支持 rabbitMq :http://www.rabbitmq.com/download.html erlang  :ht ...

  6. 日志记录发布网站之后不成功,对路径“C:\Inetpub\wwwroot\***\***.xls”的访问被拒绝。

    主要是web程序的根目录文件夹路径访问权限不够,新增加一个everyone的完全控制读写的权限即可!---------折磨了两天,才发现使劲使错了地方. 另外: 一定谨记!!!!! 所写的路径如果不存 ...

  7. Dubbo简单理解

    Dubbo 致力于提供高性能和透明化的RPC远程服务调用方案,以及SOA服务治理方案.简单的说,Dubbo就是个服务框架,如果没有分布式的需求,其实是不需要用的,只有在分布式的时候,才有Dubbo这样 ...

  8. SVN的基本操作

    右键SVN Commit 提交成功了,我们把SVN的服务器端刷新一下 所有的操作如果只是删除本地的文件都不会影响服务器端的文件,除非右键SVN Commit删除文件或者是新增文件才会对服务器端的仓库里 ...

  9. cdoj841-休生伤杜景死惊开 (逆序数变形)【线段树 树状数组】

    http://acm.uestc.edu.cn/#/problem/show/841 休生伤杜景死惊开 Time Limit: 3000/1000MS (Java/Others)     Memory ...

  10. python之socket运用2

    今天实现在客户端和服务端之间进行持续的通信 客户端代码 import socket ip_port = ("127.0.0.1",3000) sk = socket.socket( ...