Skip to content

Instantly share code, notes, and snippets.

Venkatesh-Prasad Ranganath rvprasad

Block or report user

Report or block rvprasad

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
rvprasad / hostfile
Last active Jan 31, 2020
Compare map's performance of mpi4py module and Python's multiprocessing module
View hostfile
localhost slots=9
rvprasad /
Last active Dec 24, 2019
Compare performance of set and list in identifying unique values
import random
import statistics
from timeit import default_timer as timer
def time_function(f, data):
times = []
for _ in range(0, 20):
start = timer()
times.append(timer() - start)
rvprasad /
Last active Dec 23, 2019
Group files based on the their modification time. Great for organizing photos and videos. Requires Python 3.7+.
import argparse
import glob
import hashlib
import logging
import os
import pathlib
import re
import shutil
import sys
import time
rvprasad /
Last active Oct 20, 2019
Explores performance of shared memory support available in multiprocessing library in Python 3.8.
# Python -- v3.8
from multiprocessing import Process, Queue, managers
import time
def worker(id, data, queue, *args):
tmp1 = time.time()
if args:
for i in range(args[0], args[1]):
rvprasad / variance.kt
Last active Apr 21, 2019
Understanding Contravariance and Covariance via Kotlin
View variance.kt
class Producer<out T: Any>(val e:T) {
fun read(): T = e
class Consumer<in T: Any>() {
private lateinit var e: T
fun write(v: T): Unit { e = v }
fun main() {
rvprasad / howManyLongsCanWeLoad.scala
Last active Mar 7, 2019
A script to identify how many longs can we store at a time with given heap size on JVM
View howManyLongsCanWeLoad.scala
import scala.collection.mutable.ArrayBuffer
import scala.util.Random
object M {
def main(args: Array[String]) {
val t = new ArrayBuffer[Long]()
while (true) {
t += Random.nextLong
if (t.length % 10000 == 0) {
rvprasad / parallelStreamAndAsSequence.kts
Last active Feb 21, 2019
Java parallel stream is significantly faster than the same stream converted into a Kotlin sequence
View parallelStreamAndAsSequence.kts
import kotlin.streams.asSequence
import kotlin.system.measureTimeMillis
val k = 500000000L
println(measureTimeMillis {, k)
.map { it.toString().length.toLong() }
rvprasad / permutations.kt
Last active Feb 19, 2019
Permutation Generator (Algorithm from Cameron's "Combinatorics: Topics, Techniques, Algorithms")
View permutations.kt
class PermutationGenerator(numOfValues:Int) : Iterator<List<Int>> {
private val maxPos = numOfValues - 1
private val values = (0..maxPos).shuffled()
private var currPerm = (0..maxPos).toMutableList()
@Synchronized override fun hasNext() = currPerm.isNotEmpty()
@Synchronized override fun next(): List<Int> {
val perm = currPerm.toList()
val j = (maxPos - 1 downTo 0).find { currPerm[it] < currPerm[it + 1] }
rvprasad / io-measure.cpp
Last active Feb 14, 2019
Measure throughput of default buffered I/O in different programming languages
View io-measure.cpp
#include <chrono>
#include <fstream>
#include <iostream>
using namespace std;
int k = 256;
int numOfNums = k * 1024 * 1024;
int reps = 6;
void writeUsingFile(string fileName) {
rvprasad / iperf-client-best-case.yml
Last active Feb 5, 2019
Measure network throughput in best case scenario -- one-to-one
View iperf-client-best-case.yml
- hosts: worker_raspi
remote_user: life
strategy: free
- name: iperf1
shell: iperf -t 20 -c
when: ansible_host == ''
- name: iperf2
shell: iperf -t 20 -c
when: ansible_host == ''
You can’t perform that action at this time.