How to use drop_caches method in avocado

Best Python code snippet using avocado_python

cache.py

Source:cache.py Github

copy

Full Screen

1import os2import subprocess3import datetime4NUM_RUN=15# cache measurement6def subprocess_cmd(command):7 process = subprocess.Popen(command,stdout=subprocess.PIPE, shell=True)8 proc_stdout = process.communicate()[0].strip()9 # print (proc_stdout)10optimizatino_flag=[" ",11 "#define MAIN_BLOCK_SIZE 1000",12 "#define INIT_INLINE 1",13 "#define FASTNOTCH 1", 14 "#define QRSFILT_OPT 1 \n#define BLOCKING_SIZE_QRSFILT 5",15 "#define BDAC_OPT 1",16 "#define AVX_OPT 1",17 "#define NOISECHK_OPT 1"]18# blocksizes = [1,2,5,10,20,50,100,200,500,1000,2000,4000,7200]19now = datetime.datetime.now()20nowtime=now.strftime("%Y-%m-%d_%H:%M:%S")21outputfile = "cache_"+nowtime22# for bs in blocksizes:23for step, opt in enumerate(optimizatino_flag):24 if step != 0:25 with open("../../hamilton_inline/performance.h","w") as config_file:26 config_file.write("#define OPERATION_COUNTER \n#define RUNTIME_MEASURE\n#define PRINT \n")27 for i in optimizatino_flag[:step+1]:28 config_file.write("%s\n"%(i))29 # recompile the program30 subprocess_cmd("cd ../../hamilton_inline/; make clean all")31 #flush disk cache32 subprocess_cmd("sync; echo 1 > /proc/sys/vm/drop_caches")33 # subprocess_cmd("echo Block Size: %s >> %s" %(bs,outputfile))34 subprocess_cmd("echo optimization step: %s >> %s" %(step,outputfile))35 for ct in range(NUM_RUN):36 if step != 0:37 subprocess_cmd("perf stat -e L1-dcache-loads,L1-dcache-load-misses,L1-dcache-stores ../../hamilton_inline/ourtest 2>&1 | tee -a %s"%(outputfile))38 #flush disk cache39 subprocess_cmd("sync; echo 1 > /proc/sys/vm/drop_caches")40 subprocess_cmd("perf stat -e dTLB-loads,dTLB-load-misses,dTLB-prefetch-misses ../../hamilton_inline/ourtest 2>&1 | tee -a %s"%(outputfile))41 #flush disk cache42 subprocess_cmd("sync; echo 1 > /proc/sys/vm/drop_caches")43 subprocess_cmd("perf stat -e LLC-loads,LLC-load-misses,LLC-stores,LLC-prefetches ../../hamilton_inline/ourtest 2>&1 | tee -a %s"%(outputfile))44 #flush disk cache45 subprocess_cmd("sync; echo 1 > /proc/sys/vm/drop_caches")46 47 subprocess_cmd("perf stat -e cycles,instructions,cache-references,cache-misses,bus-cycles ../../hamilton_inline/ourtest 2>&1 | tee -a %s"%(outputfile))48 #flush disk cache49 subprocess_cmd("sync; echo 1 > /proc/sys/vm/drop_caches")50 subprocess_cmd("perf stat -e icache.hit,icache.misses ../../hamilton_inline/ourtest 2>&1 | tee -a %s"%(outputfile))51 #flush disk cache52 subprocess_cmd("sync; echo 1 > /proc/sys/vm/drop_caches")53 else: 54 subprocess_cmd("perf stat -e L1-dcache-loads,L1-dcache-load-misses,L1-dcache-stores ../../hamilton_float/ourtest 2>&1 | tee -a %s"%(outputfile))55 #flush disk cache56 subprocess_cmd("sync; echo 1 > /proc/sys/vm/drop_caches")57 subprocess_cmd("perf stat -e dTLB-loads,dTLB-load-misses,dTLB-prefetch-misses ../../hamilton_float/ourtest 2>&1 | tee -a %s"%(outputfile))58 #flush disk cache59 subprocess_cmd("sync; echo 1 > /proc/sys/vm/drop_caches")60 subprocess_cmd("perf stat -e LLC-loads,LLC-load-misses,LLC-stores,LLC-prefetches ../../hamilton_float/ourtest 2>&1 | tee -a %s"%(outputfile))61 #flush disk cache62 subprocess_cmd("sync; echo 1 > /proc/sys/vm/drop_caches")63 64 subprocess_cmd("perf stat -e cycles,instructions,cache-references,cache-misses,bus-cycles ../../hamilton_float/ourtest 2>&1 | tee -a %s"%(outputfile))65 #flush disk cache66 subprocess_cmd("sync; echo 1 > /proc/sys/vm/drop_caches")67 subprocess_cmd("perf stat -e icache.hit,icache.misses ../../hamilton_float/ourtest 2>&1 | tee -a %s"%(outputfile))68 #flush disk cache...

Full Screen

Full Screen

bench.py

Source:bench.py Github

copy

Full Screen

1import pyarrow.feather as feather2import pyarrow.parquet as pq3import time4import os5def drop_caches():6 os.system('sync')7 os.system('echo 3 > /proc/sys/vm/drop_caches')8 os.system('sync')9read_time = list()10for i in range(50):11 drop_caches()12 s = time.time()13 open('128MB.feather', 'rb').read()14 e = time.time()15 read_time.append(e-s)16print("read feather blob:", sum(read_time)/len(read_time))17read_time = list()18for i in range(50):19 drop_caches()20 s = time.time()21 open('128MB.parquet', 'rb').read()22 e = time.time()23 read_time.append(e-s)24print("read pq blob:", sum(read_time)/len(read_time))25## parquet26pq_time = list()27for i in range(50):28 drop_caches()29 s = time.time()30 table = pq.read_table('128MB.parquet')31 e = time.time()32 pq_time.append(e-s)33print("parquet all columns:", sum(pq_time)/len(pq_time))34## feather35feather_time = list()36for i in range(50):37 drop_caches()38 s = time.time()39 read_df = feather.read_table('128MB.feather', memory_map=True)40 e = time.time()41 feather_time.append(e-s)42print("feather all columns: ", sum(feather_time)/len(feather_time))43## parquet44pq_time = list()45for i in range(50):46 drop_caches()47 s = time.time()48 table = pq.read_table('128MB.parquet', columns=['total_amount'])49 e = time.time()50 pq_time.append(e-s)51print("parquet single column:", sum(pq_time)/len(pq_time))52## feather53feather_time = list()54for i in range(50):55 drop_caches()56 s = time.time()57 read_df = feather.read_table('128MB.feather', columns=['total_amount'], memory_map=True)58 e = time.time()59 feather_time.append(e-s)...

Full Screen

Full Screen

run-read.py

Source:run-read.py Github

copy

Full Screen

1#!/usr/bin/python2import re3import sys4import os5import time6def main():7 os.system("echo 1 > /proc/sys/vm/drop_caches")8 os.system("fio fio-read-1")9 os.system("echo 1 > /proc/sys/vm/drop_caches")10 os.system("fio fio-read-2")11 os.system("echo 1 > /proc/sys/vm/drop_caches")12 os.system("fio fio-read-4")13 os.system("echo 1 > /proc/sys/vm/drop_caches")14 os.system("fio fio-read-8")15 os.system("echo 1 > /proc/sys/vm/drop_caches")16 os.system("fio fio-read-16")17 print "done."18 return...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run avocado automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful