Skip to content

Instantly share code, notes, and snippets.

@cycyyy
cycyyy / lurker.page_rank.cpp
Last active June 26, 2019 18:16
lurker.page_rank.cpp
#include <iostream>
#include <fstream>
#include <vector>
#include <map>
#include <string>
#include <sstream>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <cmath>
PERF_COUNT_HW_CPU_CYCLES:31.65%
0x7f16c1b82600 __iscanonicall /lib/x86_64-linux-gnu/libm.so.6
0x7f16b9a5db3b PyUFunc_d_d /home/ychen/.local/lib/python3.6/site-packages/numpy/core/_multiarray_umath.cpython-36m-x86_64-linux-gnu.so
0x7f16b9b78090 trivial_two_operand_loop /home/ychen/.local/lib/python3.6/site-packages/numpy/core/_multiarray_umath.cpython-36m-x86_64-linux-gnu.so
0x7f16b9b7c770 execute_legacy_ufunc_loop /home/ychen/.local/lib/python3.6/site-packages/numpy/core/_multiarray_umath.cpython-36m-x86_64-linux-gnu.so
0x7f16b9b7e950 PyUFunc_GenericFunction /home/ychen/.local/lib/python3.6/site-packages/numpy/core/_multiarray_umath.cpython-36m-x86_64-linux-gnu.so
0x7f16b9b81540 ufunc_generic_call /home/ychen/.local/lib/python3.6/site-packages/numpy/core/_multiarray_umath.cpython-36m-x86_64-linux-gnu.so
0x57ea70 _PyObject_FastCallKeywords python3
0x4f83a0 PyEval_CallObjectWithKeywords python3
0x4f9460 arr3 = np.log(arr3) ../python/num.py:15
PERF_COUNT_HW_CPU_CYCLES:9.71%
0x4f9460 py = y + yy ../python/dijkstra.py:141
0x4f7860 PyEval_CallObjectWithKeywords python3
0x4f83a0 PyEval_CallObjectWithKeywords python3
0x4f9460 solution = dijkstra(graph) ../python/dijkstra.py:157
0x4f7860 PyEval_CallObjectWithKeywords python3
0x4f83a0 PyEval_CallObjectWithKeywords python3
0x4f9460 run() ../python/dijkstra.py:172
0x4f7860 PyEval_CallObjectWithKeywords python3
0x4f83a0 PyEval_CallObjectWithKeywords python3
#!/usr/bin/python
# -*- coding: UTF-8 -*-
import os
import numpy as np
size = 10000
arr1 = np.random.rand(size, size)
arr1 = np.random.rand(size, size)
arr1 = np.random.rand(size, size)
0x7f0f2c33b740 __pyx_f_6mtrand_cont0_array /home/ychen/.local/lib/python3.6/site-packages/numpy/random/mtrand.cpython-36m-x86_64-linux-gnu.so
0x7f0f2c33d270 __pyx_pw_6mtrand_11RandomState_17random_sample /home/ychen/.local/lib/python3.6/site-packages/numpy/random/mtrand.cpython-36m-x86_64-linux-gnu.so
0x562330 PyCFunction_Call python3
0x7f0f2c31f360 __pyx_pw_6mtrand_11RandomState_29rand /home/ychen/.local/lib/python3.6/site-packages/numpy/random/mtrand.cpython-36m-x86_64-linux-gnu.so
0x4f83a0 PyEval_CallObjectWithKeywords python3
0x4f9460 arr1 = np.random.rand(size, size) ../python/num.py:8
0x4f5e40 PyEval_CallObjectWithKeywords python3
0x4f9000 PyEval_EvalCode python3
0x641580 PyParser_ASTFromFileObject python3
0x6415d0 PyRun_FileExFlags python3
@cycyyy
cycyyy / perf.c
Last active September 26, 2019 01:15
void PerfSampleWrap::signal_handler(int sig_num, siginfo_t *sig_info, void *context)
{
perf_event_mmap_page *mmap_buffer = (perf_event_mmap_page *) data->buffers[index];
while (__mmap_get_remain_size(mmap_buffer) > 0)
{
uint64_t remain = __mmap_get_remain_size(mmap_buffer);
if (remain < sizeof(perf_event_header))
{
__mmap_move_index(mmap_buffer, remain);
break;
import numpy as np
import math
from scipy.spatial import distance
n = 2000
p = 800
r = 1000
print("r/n:", r/n)
print("p/n:", p/n)
print("theory result:", math.log(1+(n-p)/(r-p)))
cmake_minimum_required(VERSION 3.0 FATAL_ERROR)
project(recsys)
find_package(Torch REQUIRED)
find_library(ROCKSDB_LIB rocksdb)
find_package(Boost 1.67.0 REQUIRED COMPONENTS system filesystem)
add_executable(recsys main.cpp)
target_link_libraries(recsys "${Boost_LIBRARIES}" "${ROCKSDB_LIB}") #It works fine
@cycyyy
cycyyy / error
Created December 23, 2020 00:52
[ 50%] Building CXX object CMakeFiles/recsys.dir/main.cpp.o
In file included from /usr/include/arrow/util/variant.h:20:0,
from /usr/include/arrow/type.h:34,
from /usr/include/parquet/properties.h:27,
from /usr/include/parquet/metadata.h:29,
from /usr/include/parquet/file_reader.h:26,
from /home/xxx/main.cpp:10:
/usr/include/arrow/vendored/variant.hpp:911:41: error: ‘lib’ has not been declared
struct variant_size<variant<Ts...>> : lib::size_constant<sizeof...(Ts)> {};
^~~
from deepctr_torch.inputs import SparseFeat, DenseFeat
import numpy as np
import torch
from torch import nn
import torch.utils.data as td
import torch.nn.functional as F
from tqdm import tqdm
import sys, os
sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))