我有一个有 60 列的表。其中 20 个是“NotEmpty”,6 个是“NotNull”。
我有空值和 Null 值(在我的情况下总是意味着“没有数据”)。我想将列与一种类型的约束统一起来。
我读过空值很便宜(以字节大小计)。那么也许使用 NotEmpty 约束?但也许 NotNull 约束表现更好?coalesce()或者也许在检索数据时同时拥有值和使用会更好?
Postgres 9.x 中的约束CHECK成本是多少?你的经历怎么样?有什么基准吗?INSERTUPDATE
sql postgresql benchmarking check-constraints postgresql-9.1
我正在运行一些实验来研究替代服务器端语言的可行性。更多的是出于学术目的而不是出于实际目的。
我选择的三个是 Javascript(在 Node 上)、PHP 和 Dart。
我尝试使用迭代创建一个公平的测试。这些测试如下:
JavaScript:
run();run();run();run();run();run();run();run();run();
function run() {
var sample = '';
for (var i = 0; i < 20000000; i++) {
sample = 'sample-'+i;
}
}
Run Code Online (Sandbox Code Playgroud)
PHP:
<?php
run();run();run();run();run();run();run();run();run();
function run()
{
$sample = '';
for ($i = 0; $i < 20000000; $i++) {
$sample = 'sample-'.$i;
}
}
Run Code Online (Sandbox Code Playgroud)
镖:
main() {
run();run();run();run();run();run();run();run();run();
}
run()
{
String sample = '';
for (int i = 0; i < 20000000; i++) {
sample = 'sample-'+i.toString();
} …Run Code Online (Sandbox Code Playgroud) 常用(?)的 DBMS 基准之一称为 SSB,星型模式基准)。要运行它,您需要生成模式,即包含数据的表。嗯,你可以在各种地方找到一个生成器程序(在 github 上):
\n\n也可能在其他地方。我不确定它们都有完全相同的代码,但我似乎遇到了同样的问题。我正在使用 Linux 64 位系统(Kubuntu 14.04,如果有帮助的话);并尝试从该包构建并运行“dbgen\”程序。
\n\n构建时,我收到与类型/大小相关的警告:
\n\nme@myhost:~/src/ssb-dbgen$ make\n... etc. etc. ...\ngcc -O -DDBNAME=\\"dss\\" -DLINUX -DDB2 -DSSBM -c -o varsub.o varsub.c\nrnd.c: In function \xd7\x92row_stop\xd7\x92:\nrnd.c:60:6: warning: format \xd7\x92%d\xd7\x92 expects argument of type \xd7\x92int\xd7\x92, but argument 4 has type \xd7\x92long int\xd7\x92 [-Wformat=]\n i, Seed[i].usage);\n ^\ndriver.c: In function \xd7\x92partial\xd7\x92:\ndriver.c:606:4: warning: format \xd7\x92%d\xd7\x92 expects argument of type \xd7\x92int\xd7\x92, but argument 4 has type \xd7\x92long int\xd7\x92 …Run Code Online (Sandbox Code Playgroud) 这个问题类似于IPC性能:命名管道与套接字,但重点关注匿名而不是命名管道:不同操作系统和不同传输大小的匿名管道和TCP连接之间的性能差异如何?
我使用以下代码在 c 和 java 中实现并基准测试了以下函数。对于 c,我得到大约 1.688852 秒,而对于 java,只需要 0.355038 秒。即使我删除该sqrt函数,手动内联代码或更改函数签名以接受 6 个double坐标(以避免通过指针访问),c 时间流逝也不会改善太多。
我正在编译 c 程序,例如cc -O2 main.c -lm. 对于java,我使用默认的jvm选项(java 8,openjdk)在intellij idea中运行应用程序。
C:
\n#include <math.h>\n#include <stdio.h>\n#include <time.h>\n\ntypedef struct point3d\n{\n double x;\n double y;\n double z;\n} point3d_t;\n\ndouble distance(point3d_t *from, point3d_t *to);\n\nint main(int argc, char const *argv[])\n{\n point3d_t from = {.x = 2.3, .y = 3.45, .z = 4.56};\n point3d_t to = {.x = 5.678, .y = 3.45, .z = -9.0781};\n\n double …Run Code Online (Sandbox Code Playgroud) 我有一个ArrayList,其中的数字从 10 MM 到 20 MM
List<Long> l = new ArrayList<>();
for (long i = 10_000_000; i < 20_000_000; i++) {
l.add(i);
}
Run Code Online (Sandbox Code Playgroud)
为什么sum()函数在排序数组上比在未排序数组上更快?
public class Main {
public static void main(String[] args) {
List<Long> l = new ArrayList<>();
for (long i = 10_000_000; i < 20_000_000; i++) {
l.add(i);
}
System.out.println(sum(l));
Collections.shuffle(l);
System.out.println(sum(l));
Collections.sort(l);
System.out.println(sum(l));
}
static long sum(List<Long> l) {
long started = System.nanoTime();
long result = 0;
for (long v : l) { …Run Code Online (Sandbox Code Playgroud) 我正在使用的处理器架构有一个时间标签计数器,我想读出来进行性能测量.时间标记计数器的内存映射到地址0x90000008.我使用以下例程从时间计数器读取值,但打印输出的差异始终为零.谁知道我错过了什么?
char* const ADDR = (char *) 0x90000008;
unsigned long cycle_count_val() {
unsigned long res;
asm volatile (
"set ADDR, %%l0 \n\t"
"ld [%%l0], %0 \n\t"
: "=r" (res)
:
: "%l0"
);
return res;
}
....
unsigned long start = cycle_count_val();
execute_benchmark();
unsigned long end = cycle_count_val();
printf("Benchmark performance(in clock cycles) = %ld \r\n", end-start);
Run Code Online (Sandbox Code Playgroud)
非常感谢你的帮助,菲尔
在我的Perl应用程序中,我需要比较文件的两个版本并检测它们是否已更改.
我正在尝试在MD5或SHA之间进行选择.这与安全无关.这是比较文件的最快方法.我倾向于MD5.
但是,当我运行基准测试时,它表示不然.
有什么建议?
这是我在应用程序中使用最大文件运行的基准测试.
Benchmark: timing 10000000 iterations of MD5, SHA...
MD5: -0.199009 wallclock secs ( 0.07 usr + 0.01 sys = 0.08 CPU) @ 125000000.00/s (n=10000000)
(warning: too few iterations for a reliable count)
SHA: 0.494412 wallclock secs ( 0.06 usr + 0.00 sys = 0.06 CPU) @ 166666666.67/s (n=10000000)
(warning: too few iterations for a reliable count)
Rate MD5 SHA
MD5 125000000/s -- -25%
SHA 166666667/s 33% --
Run Code Online (Sandbox Code Playgroud) 在您阅读我的帖子之前,请考虑到我是C和C++的新手.我主要是托管代码开发人员.
我有两段相同的代码(或者至少我相信).一个用C语言,一个用C++语言.代码基本上检查数字是否为素数,如果是,则将其存储在容器中.
C++
Main.cpp的
#include <iostream>
#include <vector>
#include <time.h>
static bool isPrime(const int& number) {
if((number & 1) == 0) {
if(number == 2)
return true;
else
return false;
}
for(int i = 3; (i * i) <= number; i++) {
if((number % i) == 0)
return false;
}
return number != 1;
}
int main(int argc, const char * argv[]) {
std::vector<int> vector;
clock_t start = clock();
for(int i = 0; i < 30000000; i++) {
if(isPrime(i))
vector.push_back(i); …Run Code Online (Sandbox Code Playgroud) benchmarking ×10
c ×3
performance ×3
c++ ×2
java ×2
arrays ×1
cpu ×1
dart ×1
filecompare ×1
go ×1
javascript ×1
linux ×1
md5 ×1
perl ×1
php ×1
pipe ×1
postgresql ×1
rdbms ×1
sha ×1
sockets ×1
sorting ×1
sql ×1
tcp ×1
testing ×1