V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
V2EX  ›  wxf666  ›  全部回复第 1 页 / 共 26 页
回复总数  519
1  2  3  4  5  6  7  8  9  10 ... 26  
@debuggerx #13 看了看 AvaloniaUI 的展示案例,确实手机端很少,只有两个。界面看起来还行。。

QT 我一时也想不到,手机上的应用有啥。。

所以你觉得 AI 的能力边界是什么呢?

其他人也能写出赚这么多钱的,那就直接让他《写一个机器人,能日种几亩田》之类的。。?

https://i.imgur.com/krir4IG.png https://i.imgur.com/krir4IG.png
@debuggerx #11 QT 、AvaloniaUI ,这些不行吗?

AI 出来后,让它《写一个日赚过万的 App 》,会咋样呢?

换句话说,AI 的能力边界是什么呢?

https://i.imgur.com/F29pmQ6.png https://i.imgur.com/F29pmQ6.png
5 小时 24 分钟前
回复了 abcbuzhiming 创建的主题 程序员 现代 web 随便一个页面都会用到 GPU 加速功能?
@kuanat #26 浏览器会利用系统的 DWM ,由其来单独合成普通页面与视频画面,而不是浏览器自己合成再提交?

放到 Windows 上说,就是利用了 DirectComposition ?

可这是 Win8 才引入的呀。。Win7- 是咋做到的呢?

https://i.imgur.com/F29pmQ6.png https://i.imgur.com/F29pmQ6.png
把设备晾在那一天,看看语音助手耗多少电、用多少流量,不就心中有数了嘛。。
4 天前
回复了 keakon 创建的主题 Redis Garnet 真比 Redis 快吗?
@hez2010 #8 如果 8 线程访问 Redis ,每个线程 pipeline 都是 1 。这算啥?
8 天前
回复了 test123abc 创建的主题 程序员 PHP 处理百万级 execl
为嘛不用 DuckDB 呢?它支持直接读取 xlsx 呀。。

速度上,之前的 1BRC (十亿行文本)挑战里,它能做到(普通人 SQL 写法)计算只用 5 秒钟。

或者,23 亿词 13GB 的英文维基文本,计算 TOP 1000 高频词,i5-8250U 轻薄本上,单线程下,只需 3 分钟,500MB 内存。。

如果你用 PHP 不能做到,更快更省资源,用用它也不错呀。。

反正我用 Java 一般写法,都要 6 分钟,2GB 内存。。

用 C++ 来写,也才勉强和它打平。。

https://i.imgur.com/krir4IG.png https://i.imgur.com/krir4IG.png
11 天前
回复了 jaween 创建的主题 MySQL 哪里有 sql 的练习可以做
《 SQL 解惑(第二版)》,里面有 75 个问题,并用 SQL 编程解决。

跟着做完,SQL 能力肯定能提升很多。。
13 天前
回复了 lulinchuanllc 创建的主题 前端开发 网页内存占用高如何优化
什么浏览器,七八百兆就崩啊?我这常年几个 G 呢。。

不会是一个页面就七八百兆吧?抖音客户端,也是 Electron ,都才四五百兆啊。。

https://i.imgur.com/veWihk6.png https://i.imgur.com/veWihk6.png
15 天前
回复了 MegatronKing 创建的主题 推广 买断制上线,一天的营收超过一个月
Deepin 20 ,打开时报错说 libstdc++.so.6 版本太低诶。。

```
/usr/share/reqable/reqable: /lib/x86_64-linux-gnu/libstdc++.so.6: version `GLIBCXX_3.4.26' not found (required by /usr/share/reqable/lib/libdesktop_multi_window_plugin.so)
/usr/share/reqable/reqable: /lib/x86_64-linux-gnu/libstdc++.so.6: version `GLIBCXX_3.4.26' not found (required by /usr/share/reqable/lib/libreqable_appdump_plugin.so)
```
15 天前
回复了 zyb201314 创建的主题 JavaScript 求助一个正则表达式.
```js
s = 'txt=123,txt=kg66vv,hhj,txt=6966,ggg'
s.match(/(?<=(?:^|,)[^=]+=)([^,]*6[^,]*)(?=,|$)/g)
```
@luozic #6 感觉 DuckDB 读文件时,性能有点问题?


感觉 DuckDB 读空缓冲区后,Writer 才能继续写。写满后,DuckDB 才去读一样?

同样的内容,会因喂给 DuckDB 的姿势不同,表现出不同的速度差异。。

就像 Python 的假多线程一样,只能有一个线程活跃。。

https://i.imgur.com/zDWIvwg.png
15 天前
回复了 ComplexPug 创建的主题 程序员 关于一个经典海量数据的问题
@ComplexPug #14 我用 Lua 写了个(可限制内存)词频统计,并和 DuckDB 比了下速度,感觉还行。


1. 测试数据

[知乎回答]( https://www.zhihu.com/answer/1906560411 ) 里,分享的《英文维基百科(仅文本版)》,并简单用脚本预处理了下(去标点、每词一行、转小写)。

解压后:13.33 GB
处理后:12.84 GB ,23 亿词(不重复的有 854W )


2. 测试结果

- DuckDB (不限制内存):4 分半( 1.0X )
- Lua(最多存100M文本):7 分半( 1.6X ),01 个共 103MB 临时文件
- Lua(最多存 10M文本):8 分钟( 1.7X ),23 个共 306MB 临时文件


3. 测试硬件:i5-8250U 低压 CPU 轻薄本。。


4. 运行截图

https://i.imgur.com/Th6QoLr.png


5. 预处理脚本

```shell
unzip -p enwiki_text.zip | tr -cs "[:alnum:]'-" '\n' | tr [:upper:] [:lower:]
```


6. Lua 脚本( V 站吞空格,所以将行首缩进,都转为全角空格了)

```lua
#!luajit
local TOP_NUM = 1000
local MAX_SIZE = tonumber(arg[1] or 16) * 2 ^ 20

local dict = {}
local dict_size = 0
local files = {}
local words = {}
local word = ''
local freq = 0

function heap_swap(heap, comp, lhs, rhs, func, next)
  if comp(heap[lhs], heap[rhs]) then
   heap[lhs], heap[rhs] = heap[rhs], heap[lhs]
   func(heap, comp, next)
  end
end

function heap_up(heap, comp, idx)
  if idx > 1 then
   local pa = math.floor(idx / 2)
   heap_swap(heap, comp, idx, pa, heap_up, pa)
  end
end

function heap_down(heap, comp, idx)
  if idx <= #heap / 2 then
   local left, right = idx * 2, idx * 2 + 1
   local son = right > #heap and left or
   (comp(heap[left], heap[right]) and left or right)
   heap_swap(heap, comp, son, idx, heap_down, son)
  end
end

function heap_push(heap, comp, val)
  table.insert(heap, val)
  heap_up(heap, comp, #heap)
end

function heap_pop(heap, comp)
  heap[1] = heap[#heap]
  table.remove(heap)
  heap_down(heap, comp, 1)
end

function heap_adjust(heap, comp, idx)
  heap_down(heap, comp, idx)
  heap_up(heap, comp, idx)
end

function comp(lhs, rhs)
  return lhs[1] < rhs[1]
end

function sorted_keys(dict)
  local keys = {}
  for k in pairs(dict) do
   table.insert(keys, k)
  end
  table.sort(keys)
  return keys
end

function push_word()
  if #word > 0 then
   if #words < TOP_NUM then
    heap_push(words, comp, {freq, word})
   elseif freq > words[1][1] then
    words[1] = {freq, word}
    heap_adjust(words, comp, 1)
   end
  end
end

function try_save_dict(new_key)
  dict_size = dict_size + (new_key and #new_key or 0)
  if not new_key or dict_size > MAX_SIZE then
   local file = io.tmpfile()
   for idx, key in ipairs(sorted_keys(dict)) do
    file:write(dict[key], ' ', key, '\n')
   end
   dict = {}
   file:seek('set')
   dict_size = new_key and #new_key
   table.insert(files, {'', 0, file})
  end
end

for word in io.lines() do
  dict[word] = (dict[word] or try_save_dict(word) or 0) + 1
end
try_save_dict()

while #files > 0 do
  local file, read_ok = files[1]
  if word == file[1] then
   freq = freq + file[2]
  else
   push_word()
   word, freq = file[1], file[2]
  end
  file[2], read_ok, file[1] = file[3]:read('n', 1, 'l');
 (read_ok and heap_adjust or heap_pop)(files, comp, 1)
end
push_word()

table.sort(words, comp)
for i = #words, 1, -1 do
  io.write(string.format('%d %s\n', words[i][1], words[i][2]))
end
```
16 天前
回复了 AoEiuV020JP 创建的主题 程序员 电脑内存都被谁占了
@AoEiuV020JP 总感觉,Win10+ 有内存泄漏。。

表现为,用了几天后,关闭所有程序,但系统还会吃很多内存。。(比如一半以上。。)

Win7 、XP ,好像没有这种现象。。
@bthulu 楼上这么多人给出的方案,你给点反馈呀?

1. 全读出来,存数组里,直接遍历找
2. 全读出来,存哈希表里,精确查找
3. 全读出来,排序后存数组里,可范围查找
4. 全读出来,丢到 Redis 里,再查
5. 全读出来,每个丢到一个文件里,根据文件名查
6. 用 MySQL 内存表
7. 用 SQLite 内存表
8. 用 MySQL 存储过程写逻辑


个人认为,从速度上说,内存里用哈希表/ B 树/排序后数组二分查找,

> SQLite 内存表(这个每秒只能几万次)> MySQL 存储过程(页面缓存还是有些慢)>数组遍历( 99%无用功)

>丢到 Redis 查(几千次网络开销)> MySQL 内存表(几千次网络开销)>存几万个文件再查(几千次文件系统开销)
17 天前
回复了 wangpugod2003 创建的主题 程序员 讨论一道面试题啊(take home task)
@WoodsGao #27 题目的原文件,应该是十进制字符串吧。。

就算是二进制数据,也应该是 8 字节,俩 int32 呀。。

https://i.imgur.com/krir4IG.png https://i.imgur.com/krir4IG.png
17 天前
回复了 wangpugod2003 创建的主题 程序员 讨论一道面试题啊(take home task)
@wangpugod2003 #2 楼主,我突然对你的 10GB 文件感兴趣。。


假设你 10GB 二十亿条,那平均每条 (10 << 30) / 2e9 = 5 字节,

去除空格、换行 2 字节,还剩 3 字节,你是怎么存得下 10 位数的 ID ,和几位数的 value 呢?


https://i.imgur.com/F29pmQ6.png https://i.imgur.com/F29pmQ6.png https://i.imgur.com/F29pmQ6.png
18 天前
回复了 wangpugod2003 创建的主题 程序员 讨论一道面试题啊(take home task)
@wxf666 #5 等会儿,我以为是,求出现最多次数的 ID 了。。

那你这个算法,应该没问题的呀?

https://i.imgur.com/F29pmQ6.png https://i.imgur.com/F29pmQ6.png
18 天前
回复了 wangpugod2003 创建的主题 程序员 讨论一道面试题啊(take home task)
极端情况下,每个 ID 只出现一次,

你是要在内存里,保留整个 几百 GB 的 ID 吗?

https://i.imgur.com/F29pmQ6.png https://i.imgur.com/F29pmQ6.png
@bthulu #3 键是宽度值,值是(库存 ID/引用/指针/…)数组?

或者,你也模仿数据库的底层存储结构,内存里也用 B 树存储呗。。
全读出来,存到 HashMap 里,不也相当于有索引了吗?

https://i.imgur.com/F29pmQ6.png https://i.imgur.com/F29pmQ6.png
1  2  3  4  5  6  7  8  9  10 ... 26  
关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   2124 人在线   最高记录 6543   ·     Select Language
创意工作者们的社区
World is powered by solitude
VERSION: 3.9.8.5 · 33ms · UTC 10:41 · PVG 18:41 · LAX 03:41 · JFK 06:41
Developed with CodeLauncher
♥ Do have faith in what you're doing.