데이터 베이스 MySQL 튜토리얼 多种方式测试redis入库性能

多种方式测试redis入库性能

Jun 07, 2016 pm 04:31 PM
redis 성능 방법 시험

? ? Transaction Pipeline 耗时(s) 测试一: N N 311 测试二: N Y 10 测试三: Y Y 7 测试四: Y N 10 ? 结论:Pipeline + Transaction方式是几种插入方式中性能最好的。虽然有点意外,但测试多次仍然是这个结论。 ? 测试代码如下: ? import org.apache.

?

? Transaction Pipeline 耗时(s)
测试一: N N 311
测试二: N Y 10
测试三: Y Y 7
测试四: Y N 10

?

结论:Pipeline + Transaction方式是几种插入方式中性能最好的。虽然有点意外,但测试多次仍然是这个结论。

?

测试代码如下:

?

import org.apache.commons.lang.RandomStringUtils;
import redis.clients.jedis.Jedis;
import redis.clients.jedis.JedisPool;
import redis.clients.jedis.JedisPoolConfig;
import redis.clients.jedis.Pipeline;
import redis.clients.jedis.Transaction;
public class RedisTransactionTest {
	private static String host = "xx.xx.xx.xx";
	private static JedisPool pool = new JedisPool(new JedisPoolConfig(), host);
	private long rowCount = 1000000; // 100万
	public static void main(String[] args) {
		long start = System.currentTimeMillis();
		new RedisTransactionTest().noTransactionNoPipeline();
		System.out.println("noTransactionNoPipeline use " + (System.currentTimeMillis() - start) / 1000);
		pool = new JedisPool(new JedisPoolConfig(), host);
		start = System.currentTimeMillis();
		new RedisTransactionTest().pipelineWithoutTransaction();
		System.out.println("pipelineWithoutTransaction use " + (System.currentTimeMillis() - start) / 1000);
		pool = new JedisPool(new JedisPoolConfig(), host);
		start = System.currentTimeMillis();
		new RedisTransactionTest().pipelineWithTransaction();
		System.out.println("pipelineWithTransaction use " + (System.currentTimeMillis() - start) / 1000);
		pool = new JedisPool(new JedisPoolConfig(), host);
		start = System.currentTimeMillis();
		new RedisTransactionTest().transactionNoPipeline();
		System.out.println("transactionNoPipeline use " + (System.currentTimeMillis() - start) / 1000);
	}
	public void pipelineWithoutTransaction() {
		Jedis jedis = pool.getResource();
		try {
			Pipeline p = jedis.pipelined();
			for (int i = 0; i 
  <p>?--end</p>
  <p>?</p>
  <p>?</p>

               <br> <br>
                 已有   <strong>0</strong> 人发表留言,猛击-&gt;&gt;  <strong>这里</strong> <br> <br>
ITeye推荐
 <br>
 
로그인 후 복사
  • —软件人才免语言低担保 赴美带薪读研!—



多种方式测试redis入库性能

본 웹사이트의 성명
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.

뜨거운 기사 태그

메모장++7.3.1

메모장++7.3.1

사용하기 쉬운 무료 코드 편집기

SublimeText3 중국어 버전

SublimeText3 중국어 버전

중국어 버전, 사용하기 매우 쉽습니다.

스튜디오 13.0.1 보내기

스튜디오 13.0.1 보내기

강력한 PHP 통합 개발 환경

드림위버 CS6

드림위버 CS6

시각적 웹 개발 도구

SublimeText3 Mac 버전

SublimeText3 Mac 버전

신 수준의 코드 편집 소프트웨어(SublimeText3)

Windows 11 10.0.22000.100 설치 시 발생하는 0x80242008 오류 해결 방법 Windows 11 10.0.22000.100 설치 시 발생하는 0x80242008 오류 해결 방법 May 08, 2024 pm 03:50 PM

Windows 11 10.0.22000.100 설치 시 발생하는 0x80242008 오류 해결 방법

Golang API 캐싱 전략 및 최적화 Golang API 캐싱 전략 및 최적화 May 07, 2024 pm 02:12 PM

Golang API 캐싱 전략 및 최적화

다양한 Java 프레임워크의 성능 비교 다양한 Java 프레임워크의 성능 비교 Jun 05, 2024 pm 07:14 PM

다양한 Java 프레임워크의 성능 비교

PHP 개발의 캐싱 메커니즘 및 응용 실습 PHP 개발의 캐싱 메커니즘 및 응용 실습 May 09, 2024 pm 01:30 PM

PHP 개발의 캐싱 메커니즘 및 응용 실습

C++에서 멀티스레드 프로그램의 성능을 최적화하는 방법은 무엇입니까? C++에서 멀티스레드 프로그램의 성능을 최적화하는 방법은 무엇입니까? Jun 05, 2024 pm 02:04 PM

C++에서 멀티스레드 프로그램의 성능을 최적화하는 방법은 무엇입니까?

Win11 영어 21996을 중국어 간체 22000으로 업그레이드하는 방법_Win11 영어 21996을 중국어 간체 22000으로 업그레이드하는 방법 Win11 영어 21996을 중국어 간체 22000으로 업그레이드하는 방법_Win11 영어 21996을 중국어 간체 22000으로 업그레이드하는 방법 May 08, 2024 pm 05:10 PM

Win11 영어 21996을 중국어 간체 22000으로 업그레이드하는 방법_Win11 영어 21996을 중국어 간체 22000으로 업그레이드하는 방법

C++와 다른 언어의 성능 비교 C++와 다른 언어의 성능 비교 Jun 01, 2024 pm 10:04 PM

C++와 다른 언어의 성능 비교

Win11에서 다운로드한 업데이트 파일 찾는 방법_Win11에서 다운로드한 업데이트 파일 위치 공유 Win11에서 다운로드한 업데이트 파일 찾는 방법_Win11에서 다운로드한 업데이트 파일 위치 공유 May 08, 2024 am 10:34 AM

Win11에서 다운로드한 업데이트 파일 찾는 방법_Win11에서 다운로드한 업데이트 파일 위치 공유

See all articles