Skip to content

Instantly share code, notes, and snippets.

View luchenqun's full-sized avatar

Luke luchenqun

View GitHub Profile

/* interfaces for generic */   int Del(const std::string &strKey, long *pnVal = nullptr, Pipeline ppLine = nullptr)
int Dump(const std::string &strKey, std::string *pstrVal, Pipeline ppLine = nullptr)
int Exists(const std::string &strKey, long *pnVal, Pipeline ppLine = nullptr)
int Expire(const std::string &strKey, long nSec, long *pnVal = nullptr, Pipeline ppLine = nullptr)
int Expireat(const std::string &strKey, long nTime, long *pnVal = nullptr, Pipeline ppLine = nullptr)
int Keys(const std::string &strPattern, std::vectorstd::string *pvecVal)
int Persist(const std::string &strKey, long *pnVal = nullptr, Pipeline ppLine = nullptr)
int Pexpire(const

var readline = require('readline');
var fs = require('fs');
var os = require('os');
var fReadName = './data.cpp';
var fWriteName = './data.deal.cpp';
var fRead = fs.createReadStream(fReadName);
var fWrite = fs.createWriteStream(fWriteName);
var objReadline = readline.createInterface({
class Redis
{
public:
redisContext* context;
Redis(const char * ip="127.0.0.1",int port=6379){
this->context = redisConnect(ip,port);
if(this->context == NULL || context->err){
if(context){
printf("Error: %s\n",context->errstr);
exit(-1);
@luchenqun
luchenqun / csdn.js
Last active January 18, 2018 07:54
// ==UserScript==
// @name csdn
// @namespace http://tampermonkey.net/
// @version 0.1
// @description try to take over the world!
// @author You
// @match http://*/*
// @grant none
// ==/UserScript==
#include <string>
#include <thread>
#include "RedisClient.h"
void f(int index){
std::string strKey = "name";
std::string strVal;
CRedisClient* r = CRedisClient::Instance();
int ret = r->Get(strKey, &strVal);
std::cout << index << ":" << std::this_thread::get_id() << " request ret = " << ret << ", val = " << strVal << std::endl;
@luchenqun
luchenqun / gtest.js
Last active February 27, 2018 14:34
var readline = require('readline');
var fs = require('fs');
var os = require('os');
var fReadName = './test.cpp';
var fWriteName = './test.deal.cpp';
var fRead = fs.createReadStream(fReadName);
var fWrite = fs.createWriteStream(fWriteName);
var objReadline = readline.createInterface({
@luchenqun
luchenqun / stress-test.md
Created March 19, 2018 10:28
ws与http分别调用10万次压力测试

通讯协议简单压力测试

websocket 或者 http分别调用eth_accounts,接收到后台数据之后立马再次调用此接口。调用10万次,结果大概如下: websocket: 17287ms
http: 37491ms

Websocket压测代码

const WebSocket = require('ws');
const ws = new WebSocket('ws://127.0.0.1:6788');
var id = 0;
import { app, BrowserWindow } from 'electron'
import { autoUpdater } from "electron-updater"
import log from "electron-log"
autoUpdater.logger = log;
autoUpdater.logger.transports.file.level = "info";
log.info("App starting...");
/**
var keythereum = require("keythereum");
var path = require("path");
var fs = require("fs-extra");
var createKeccakHash = require("keccak/js");
var os = require('os');
var secp256k1 = require("secp256k1/elliptic");
var ffi = require('ffi');
var ref = require('ref');
var sha3 = require('crypto-js/sha3');
@luchenqun
luchenqun / eth.cpp
Last active August 21, 2018 02:24
eth_getTransactionReceipt 压测
Json::Value Eth::eth_getTransactionByHash(string const& _transactionHash)
{
static int count = 0;
static int totalSpend = 0;
try
{
h256 h = jsToFixed<32>(_transactionHash);
std::chrono:: steady_clock :: time_point t1 = std::chrono:: steady_clock ::now();
bool ret = client()->isKnownTransaction(h);
std::chrono:: steady_clock :: time_point t2 = std::chrono:: steady_clock ::now();