我使用mochiweb的本机MySQL驱动程序(http://code.google.com/p/erlang-mysql-driver/).当我在shell模式下尝试MySQL驱动程序时,所有都很好.但是当我用Mochiweb编写一些代码时,它报告了以下错误:
=CRASH REPORT==== 4-Jul-2009::04:44:29 ===
crasher:
initial call: mochiweb_socket_server:acceptor_loop/1
pid: <0.61.0>
registered_name: []
exception error: no function clause matching
mysql:fetch(p1,<<"SELECT * FROM cdb_forums LIMIT 10">>)
in function perly_web:loop/2
in call from mochiweb_http:headers/5
ancestors: [perly_web,perly_sup,<0.58.0>]
messages: []
links: [<0.60.0>,#Port<0.965>]
dictionary: [{mochiweb_request_body,undefined},
{mochiweb_request_qs,[]},
{mochiweb_request_post,[]},
{mochiweb_request_path,"/online"},
{mochiweb_request_cookie,
[{"04c_sid","hG9Oyv"},
{"04c_visitedfid","2"},
{"kQx_cookietime","2592000"},
{"kQx_loginuser","admin"},
{"kQx_activationauth",
"98b3mdX86fKT9dI4WyKuL61Tqxk%2BW1r6ACpHp9y8itH2xQ"},
{"smile","1D1"}]}]
trap_exit: false
status: running
heap_size: 1597
stack_size: 24
reductions: 5188
neighbours:
Run Code Online (Sandbox Code Playgroud)
我在Mochiweb写的代码是
start(Options) ->
{DocRoot, Options1} = get_option(docroot, Options),
Loop = fun (Req) ->
?MODULE:loop(Req, DocRoot)
end, …Run Code Online (Sandbox Code Playgroud) 我在linux上使用time命令来测量我的程序花了多长时间,在我的代码中我已经把计时器用来计算时间
time took calculated by program: 71.320 sec
real 1m27.268s
user 1m7.607s
sys 0m3.785s
Run Code Online (Sandbox Code Playgroud)
我不知道为什么我的程序实时超过计算,如何找到原因并解决它?
================================================== ====
这是我在代码中计算时间的方法;
clock_t cl;
cl = clock();
do_some_work();
cl = clock() - cl;
float seconds = 1.0 * cl / CLOCKS_PER_SEC;
printf("time took: %.3f sec\n", seconds);
Run Code Online (Sandbox Code Playgroud) 我有一个用Visual C++ 2012编写的程序,我试图调用用Delphi编写的函数(我没有源代码).这是Visual C++中的代码:
int (_fastcall *test)(void*) = (int(_fastcall *)(void*))0x00489A7D;
test((void *)0x12345678);
Run Code Online (Sandbox Code Playgroud)
但在编译的代码中它实际上是:
.text:1000113B mov eax, 489A7Dh
.text:10001140 mov ecx, 12345678h
.text:10001145 call eax
Run Code Online (Sandbox Code Playgroud)
我除外的是:
.text:1000113B mov ebx, 489A7Dh
.text:10001140 mov eax, 12345678h
.text:10001145 call ebx
Run Code Online (Sandbox Code Playgroud)
我知道'fastcall'使用EAX,ECX,EDX作为参数,但我不知道为什么Visual C++编译器使用EAX作为入口点.EAX不应该是第一个参数(12345678h)吗?
我试图在汇编代码中调用delphi函数并且它可以工作,但我真的想知道如何在不使用汇编的情况下执行此操作.
那么可以让Visual C++编译器生成代码,就像我说的那样吗?如果是的话,怎么做?
实际上我正在使用OpenCV的svm python接口,我正在尝试将数据分为4类.当标签和训练数据按顺序排列时,我的意思是例如数据分为4组,标签为1,标签2,标签3和标签4,正确的比例很低,只有50%左右.但是当我改组训练数据时,结果是合理的,大约90%是正确的.所以我的问题是:训练数据顺序是否会影响最终结果,还是我需要在训练前将数据洗牌?
目前我正在调查https://github.com/orlp/ed25519,它有签名示例,但如何使用它来加密/解密数据?谢谢
我是Qt的新手,我想做的是:
但是如何在Qt中为Webkit添加一些自定义函数/类?
我使用OpenCV和Eigen来计算SVD:
Eigen:
JacobiSVD<Matrix3f> svd(myM, ComputeFullU);
OpenCV:
cvSVD(&myM, &w, &u, 0, CV_SVD_MODIFY_A | CV_SVD_U_T);
Run Code Online (Sandbox Code Playgroud)
我专注于左奇异向量:
Eigen result:
0.0341698 -0.064916 0.997306
0.950241 -0.307051 -0.0525437
0.309635 0.949476 0.051194
OpenCV result:
[0.03417001163639093, -0.06491612525262211, 0.9973055233913801;
-0.9502414121501213, 0.3070511298822651, 0.05254390804810754;
-0.3096347347112595, -0.9494764348419663, -0.05119404985032185]
Run Code Online (Sandbox Code Playgroud)
尽管一个是浮点型而另一个是双类型,但计算的左奇异向量具有不同的符号.所以我的问题是:
由于有3代iPhone,他们的地理定位机制是什么(WiFi,GPS,还有其他什么方式?)?我最近在做iPhone开发,所以我想对此深入了解.
(我想要列出所有定位方法和具体介绍)
谢谢
我在iPod touch上运行myapp,我发现它错过了一些库.这是什么原因?
[Session started at 2010-03-19 15:57:04 +0800.]
GNU gdb 6.3.50-20050815 (Apple version gdb-1128) (Fri Dec 18 10:08:53 UTC 2009)
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB. Type "show warranty" for details.
This GDB was configured as "--host=i386-apple-darwin --target=arm-apple-darwin".tty /dev/ttys007
Loading …Run Code Online (Sandbox Code Playgroud) 我是从这样的文件中读取的:
#include <stdio.h>
int main() {
FILE *fp = fopen("sorted_hits", "r+");
while(!feof(fp)) {
int item_read;
int *buffer = (int *)malloc(sizeof(int));
item_read = fread(buffer, sizeof(int), 1, fp);
if(item_read == 0) {
printf("at file %ld\n", ftell(fp));
perror("read error:");
}
}
}
Run Code Online (Sandbox Code Playgroud)
这个文件很大,我有时会收到"错误的文件描述符"错误."ftell"表示发生错误时文件位置停止.
我不知道为什么它"有时",这是正常的吗?问题出在我的代码或硬盘中吗?怎么办呢?
打开/读/写是低级I/O函数,如果速度是我首先考虑的问题,如何在open/read/write和fopen/fread/fwrite之间进行选择?
我的程序中只使用了打开/读/写功能,但是oprofile告诉我:
20537 2.9883 tyn_indexer tyn_indexer nodes_term32_flush
11966 1.7411 vmlinux vmlinux jbd2_journal_commit_transaction
11733 1.7072 vmlinux vmlinux __strnlen_user
10741 1.5629 vmlinux vmlinux nobh_truncate_page
9728 1.4155 vmlinux vmlinux generic_file_buffered_write
9443 1.3740 vmlinux vmlinux mpage_da_map_and_submit
9023 1.3129 vmlinux vmlinux do_get_write_access
7283 1.0597 vmlinux vmlinux invalidate_interrupt31
5894 0.8576 vmlinux vmlinux write_cache_pages_da
5332 0.7758 vmlinux vmlinux journal_submit_commit_record
5316 0.7735 vmlinux vmlinux hugetlbfs_symlink
Run Code Online (Sandbox Code Playgroud)
generic_file_buffered_write如何出来,并且是开放/读/写函数缓冲?
我在Linux上使用C,我的程序是高CPU密度和I/O密度.使用time命令显示我的程序有很多开销:
real 1m4.639s
user 0m53.929s
sys 0m9.747s
Run Code Online (Sandbox Code Playgroud)
有可能找出'sys 0m9.747s'的成本并减少它吗?
=================================================
如果没有代码这个问题不容易回答,请原谅我,但我的代码太长了,无法在此发布.所以任何提示或线索也会这样做.谢谢
c ×6
linux ×4
c++ ×3
iphone ×2
algorithm ×1
assembly ×1
debugging ×1
delphi ×1
device ×1
eigen ×1
encryption ×1
erlang ×1
file ×1
fread ×1
geolocation ×1
io ×1
javascript ×1
libsvm ×1
math ×1
mysql ×1
objective-c ×1
opencv ×1
optimization ×1
qt ×1
stream ×1
visual-c++ ×1
webkit ×1