我在 Intel i3-N305 3.8GHz 和 AMD Ryzen 7 3800X 3.9GHz PC 上运行了使用 gcc-13 ( https://godbolt.org/z/qq5WrE8qx )编译的相同二进制文件。此代码使用 VCL 库(https://github.com/vectorclass/version2):
int loop_vc_nested(const array<uint8_t, H*W> &img, const array<Vec32uc, 8> &idx) {
int sum = 0;
Vec32uc vMax, iMax, vCurr, iCurr;
for (int i=0; i<H*W; i+=W) {
iMax.load(&idx[0]);
vMax.load(&img[i]);
for (int j=1; j<8; j++) {
iCurr.load(&idx[j]);
vCurr.load(&img[i+j*32]);
iMax = select(vCurr > vMax, iCurr, iMax);
vMax = max(vMax, vCurr);
}
Vec32uc vMaxAll{horizontal_max(vMax)};
sum += iMax[horizontal_find_first(vMax == vMaxAll)];
}
return sum;
}
Run Code Online (Sandbox Code Playgroud)
完整的基准源位于:https://github.com/pauljurczak/simd-benchmarks/blob/main/main-5-vcl-eve.cpp …
我有一些关于 bash 的脚本
#!/usr/bin/env bash
time_event="`date +%Y-%m-%d' '%H:%M:%S`"
current_day="`date +%Y%m%d`"
event="start_job"
src='hdfs://table1/'
dst='hdfs://table2/'
hadoop distcp -bandwidth 256 -m 50 -delete -update -strategy dynamic $src $dst &> log.txt
status=($?)
link=$(grep -oP "The url to track the job: \K[^']+" log.txt)
job=$(grep -oP "Submitting tokens for job: \K[^']+" log.txt)
hive -e "insert into table <table> partition (day) select '$src' as source_path, '$dst' as target_path, '$time_event' as time_event, '$event' as event, '$status' as status, '$link' as url_job, '$job' as url_pipeline, $current_day as day;"
Run Code Online (Sandbox Code Playgroud)
我怎样才能做到同样的事情而不在文件中写入信息并读取它?
假设我有一个数据框,如下所示;
假设我希望选择列名称中包含“cases”的列,和/或如果我希望选择数字列,如何使用 data.table 语法实现此目的?
即相当于代码tidyverse;
df <- df |>
select(contains("cases"))
Run Code Online (Sandbox Code Playgroud)
或者
df <- df |>
select(where(is.numeric))
Run Code Online (Sandbox Code Playgroud)
结果是;
我已在 Docker 上部署了 ASP.NET Core Web API。我的应用程序还与 Docker 容器中的 SQL Server 交互。
这是我的docker-compose.yml文件:
version: '3'
services:
db:
image: mcr.microsoft.com/mssql/server
container_name: db
ports:
- 1533:1433
environment:
- TZ=Asia/Tehran
- ACCEPT_EULA=Y
- MSSQL_SA_PASSWORD=******
user: root
volumes:
- ./mssql:/var/opt/mssql/data
kava-service:
image: service:1.0.0
container_name: service
expose:
- 9001
ports:
- 9001:9001
depends_on:
- db
environment:
- ASPNETCORE__ENVIRONMENT=Production
- TZ=Asia/Tehran
- AUTO__MIGRATE=true
- ConnectionStrings__BusinessDomainConnectionString=Server=db;Initial Catalog=Kava.BusinessDomain;User ID=sa;pwd=****;MultipleActiveResultSets=true;
- ConnectionStrings__RecordsConnectionString=Server=db;Initial Catalog=Kava.Records;User Id=sa;pwd=****;MultipleActiveResultSets=true;
Run Code Online (Sandbox Code Playgroud)
当我运行 docker 容器(使用docker-compose)时,它工作正常。但是,如果我重新启动此容器,它就不起作用,并且应用程序将退出并显示以下消息:
用户“sa”登录失败。原因:无法打开显式指定的数据库“Kava.BusinessDomain”[客户端:172.18.0.4] kava-service
未处理的异常。Microsoft.Data.SqlClient.SqlException(0x80131904):数据库“Kava.BusinessDomain”已存在。选择不同的数据库名称。
当我删除这个数据库时,一切正常,但我不想删除它。
在开发中(我的意思是 Visual Studio)一切都很好,但在生产中(Docker),迁移无法按预期进行。
这是我的迁移命令: …
c# docker entity-framework-core asp.net-core-webapi entity-framework-migrations
在kretprobe/sys_read探测器中,我尝试读取 BPF_MAP_TYPE_ARRAY 中的请求缓冲区(用户空间)。eBPF 验证程序抛出以下错误:
{"error": "field SyscallProbeRetRead: program syscall__probe_ret_read: load program: permission denied: invalid access to map value, value_size=70 off=0 size=16383: R1 min value is outside of the allowed memory range (truncated, 73 line(s) omitted)"}
Run Code Online (Sandbox Code Playgroud)
逻辑:如果 buf_size 大于MAX_MSG_SIZE,那么我们将读取TRACE_PARENT_SIZE或更少(取决于缓冲区的大小)到seventy_bytes_array->data,否则,我们将不会读取任何内容。
#define MAX_MSG_SIZE 16383
#define TRACE_PARENT_SIZE 70
SEC("kretprobe/sys_read")
int syscall__probe_ret_read(struct pt_regs *ctx)
{
size_t buf_size = PT_REGS_RC(ctx);
u64 id = bpf_get_current_pid_tgid();
struct data_args_t *read_args = bpf_map_lookup_elem(&active_read_args_map, &id);
if (read_args)
{
char *buf = read_args->buf; …Run Code Online (Sandbox Code Playgroud) 当我运行应用程序的预览或构建时,我不断收到以下错误
error: Sandbox: rsync.samba(3328) deny(1) file-write-create /Users/myname/Library/Developer/Xcode/DerivedData/TESTER-hbrfsmbquzqcrpfrhpzcnelekwor/Build/Intermediates.noindex/Previews/TESTER/Products/Debug-iphonesimulator/TESTER.app/Frameworks/ScrollCounter.framework/_CodeSignature (in target 'TESTER' from project 'TESTER')
error: Sandbox: rsync.samba(3329) deny(1) file-write-create /Users/myname/Library/Developer/Xcode/DerivedData/TESTER-hbrfsmbquzqcrpfrhpzcnelekwor/Build/Intermediates.noindex/Previews/TESTER/Products/Debug-iphonesimulator/TESTER.app/Frameworks/ScrollCounter.framework/.Info.plist.dyIsUH (in target 'TESTER' from project 'TESTER')
error: Sandbox: rsync.samba(3329) deny(1) file-write-create /Users/myname/Library/Developer/Xcode/DerivedData/TESTER-hbrfsmbquzqcrpfrhpzcnelekwor/Build/Intermediates.noindex/Previews/TESTER/Products/Debug-iphonesimulator/TESTER.app/Frameworks/ScrollCounter.framework/.ScrollCounter.p9bsAO (in target 'TESTER' from project 'TESTER')
Run Code Online (Sandbox Code Playgroud)
我刚刚在其中实现了一个名为 ScrollCounter 的 CocoaPods 库,我之前使用过它并将其用于其他项目,并且工作正常 - 但现在当我尝试实现它然后预览我的代码时,我收到以下沙箱错误。
我已经清理了构建文件夹,我开始了另一个新项目并重新安装了 Pod - 我的 podfile 与我的另一个工作文件相同(是的,我更改了目标)。但没有骰子。非常困惑为什么它适用于另一个项目,但不适用于我尝试启动的这个项目和任何其他项目。
尝试过这个但没有运气
chmod -R 755 /Users/myname/Documents/TESTER
Run Code Online (Sandbox Code Playgroud) 我使用C#已经有10多年了,但今天我发现Dictionary<string, int>保留了插入顺序?据我所知,Dictionary内部是使用哈希表实现的,所以内部排列应该没有特定的顺序,但是下面的测试代码似乎显示遍历时的顺序和插入的顺序是一模一样的?
const int N = 1000000;
List<string> ss = new List<string>();
Dictionary<string, int> dict = new Dictionary<string, int>();
for (int i = 0; i < N; ++i)
{
var s = string.Empty;
for (int j = 0; j < 15; ++j)
s += (char)('a' + UnityEngine.Random.Range(0, 26));
//ss.add(s);
ss.Add(new string(s));
//dict[s] = UnityEngine.Random.Range(0, 1024);
dict.Add(s, UnityEngine.Random.Range(0, 1024));
}
int same = 0;
var keys = dict.Keys.ToArray();
for (int i = 0; i < N; ++i) …Run Code Online (Sandbox Code Playgroud) 我正在尝试将 Stripe 集成到我的网站,问题是我收到以下错误:
js.stripe.com/v3/hcaptcha-invisible-078b5f9fb44d244a9ec072f93a216630.html#debugMode=false&parentOrigin=http%3A%2F%2Flocalhost:3 [仅报告] 拒绝执行内联脚本,因为它违反了以下内容安全策略指令:“脚本-src'自我'”。启用内联执行需要“unsafe-inline”关键字、哈希值(“sha256-CBu0w5uiOaPgb2R6Zgf7E0+STJHF4lcPIdhZzQXE6yk=”)或随机数(“nonce-...”)。
Stripe directives我尝试使用以下方式解决它:
<meta http-equiv="Content-Security-Policy" content="script-src 'self' js.stripe.com code.jquery.com cdn.jsdelivr.net maps.googleapis.com 'unsafe-inline';">
但是因为给出错误的文件的位置位于 上Stripe server,所以我认为这些规则不应用于该文件。
我还进行了其他集成给出相同的方法错误以确保,我已经通过将指令放入它有效,但我无法解决上述错误。
如果您想看到相同的错误,您只需转到此Stripe link并在控制台中检查浏览器即可。
为了满足高性能数学库的需求,我一直在对各种方法进行基准测试,以在 Rust vec 上进行就地操作(最好通过引用)。这些方法是:
map(),收集到一个新的 vec,并覆盖现有的for_each()这是基准测试代码:
use std::time::{Instant, Duration};
const N_ITEMS: usize = 100000;
const N_BENCH_TIMES: i32 = 100;
fn bench_simple() {
let mut a: Vec<i32> = vec![5; N_ITEMS];
for i in a.iter_mut() {
*i += 1;
}
}
fn bench_iterator() {
let mut a: Vec<i32> = vec![5; N_ITEMS];
let a: Vec<i32> = a.iter_mut().map(|x| *x + 1).collect();
}
fn bench_foreach() {
let mut a: Vec<i32> = vec![5; N_ITEMS];
a.iter_mut().for_each(|x| *x += …Run Code Online (Sandbox Code Playgroud) 我正在尝试按照此Redis 文档链接创建一个可实时搜索的名人小型数据库(使用 Python 客户端)。
我尝试了类似的代码,但最后一行(按“s”查询)应该返回两个文档,而是返回一个空白集。有人可以帮我找出我所犯的错误吗?
import redis
from redis.commands.json.path import Path
import redis.commands.search.aggregation as aggregations
import redis.commands.search.reducers as reducers
from redis.commands.search.field import TextField, NumericField, TagField
from redis.commands.search.indexDefinition import IndexDefinition, IndexType
from redis.commands.search.query import NumericFilter, Query
d1 = {"key": "shahrukh khan", "pl": '{"d": "mvtv", "id": "1234-a", "img": "foo.jpg", "t: "act", "tme": "1965-"}', "org": "1", "p": 100}
d2 = {"key": "salman khan", "pl": '{"d": "mvtv", "id": "1236-a", "img": "fool.jpg", "t: "act", "tme": "1965-"}', "org": "1", "p": 100}
d3 = {"key": …Run Code Online (Sandbox Code Playgroud) benchmarking ×2
c# ×2
avx2 ×1
bash ×1
bpf ×1
c ×1
c++ ×1
cocoapods ×1
data.table ×1
dataframe ×1
dictionary ×1
docker ×1
ebpf ×1
entity-framework-migrations ×1
html ×1
ios ×1
javascript ×1
libbpf ×1
preserve ×1
python ×1
r ×1
redis ×1
redis-py ×1
redisearch ×1
rust ×1
simd ×1
swift ×1
vector ×1
xcode ×1