Skip to content

Instantly share code, notes, and snippets.

View edefazio's full-sized avatar
🙂
Focusing

edefazio

🙂
Focusing
View GitHub Profile
@edefazio
edefazio / StaticTypeChecking_2.java
Created October 10, 2015 18:22
Static Typing (Implicit Casting) in Java illustration
package invariant;
/**
* Static Typing and Java
*
* Here are some of the purported POSITIVES of STATIC TYPING:
* <UL>
* <LI>PREVENT and DETECT ERRORS (checked at compile type) (i.e. CORRECTNESS)
* <LI>easier to REASON about the PROGRAM / METHOD
* <LI>easier to DEBUG
@edefazio
edefazio / swar.subword.SWARIntro_NoComments.java
Last active January 22, 2024 09:48
using SWAR (SIMD Within A Register) in Java using general purpose registers
package swar.subword;
public class SWAR_Intro_NoComments
{
public static void main ( String[] args )
{
int x = 12345678;
int y = 9012345;
long xyCompound = as2x32BitCompound ( x, y );
@edefazio
edefazio / swar.subword.SWAR_v_Arrays_Perf_NoComments.java
Last active October 16, 2015 13:37
Compare SWAR scanning rows of (x,y) coordinates
package swar.subword;
import java.util.Random;
public class SWAR_v_Arrays_Perf_NoComments
{
private static final int ROW_COUNT = 1000000;
private static final int SCAN_ITERATIONS = 100;
@edefazio
edefazio / swar.subword.SWAR_v_ObjectArr_Perf.java
Created October 16, 2015 14:04
Comparison between SIMD SWAR-based query and Object[] based query in Java
package swar.subword;
import java.util.Random;
public class SWAR_v_ObjectArr_Perf
{
public static class XY
{
public final int x;
public final int y;
@edefazio
edefazio / swar.subword.SWAR_v_ListLambda_Perf.java
Created October 16, 2015 15:06
Performance of SWAR query scan verses List Lambda (stream() and parallelStream())
package swar.subword;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
public class SWAR_v_ListLambda_Perf
{
public static class XY
{
@edefazio
edefazio / tf.Types_Fields_Frames.java
Last active October 16, 2015 23:05
TypeFrame data vectorization using Types, Fields, and Frames
import typeframe.api.Fields;
import typeframe.frame.bitwise.BitFrame;
import typeframe.type.ByteType;
public class Types_Fields_Frames
{
public static ByteType COMPONENT =
ByteType.INSTANCE;
public static final BitFrame RGBColorFrame =
@edefazio
edefazio / strangeunsafe.UnsafeAllocateMemoryConstructorEffectsScanPerformance.java
Created October 30, 2015 12:55
Unsafe.allocateMemory(...) performs 2x BETTER when we pass in an int verses a long (of the same value)
package strangeunsafe;
import java.lang.reflect.Field;
import java.util.Random;
import sun.misc.Unsafe
/**
* Illustrate "strange" issue where Unsafe.allocateMemory(...) performs BETTER
* when we pass in an int parameter verses a long parameter (of the same value).
@edefazio
edefazio / io.semiotics.field._UniformIntField32.java
Last active June 19, 2016 16:17
CodeMark Template for a SubWord Field mapped to bits within a 32-bit Word
/*{+packageName*/package io.semiotics.field/*}*/;
import io.semiotics.data.Word;
import io.semiotics.field.Field.Field32;
import io.semiotics.specify.Signifier;
import io.semiotics.type.InvalidBin;
import io.semiotics.type.InvalidForm;
/*{+imports*/import io.semiotics.type.primitive.IntType;/*}*/
/*{+classComment}*/
@edefazio
edefazio / io.semiotics.type.grid.__GridOfType.java
Last active December 31, 2015 16:04
Template for a 32-bit Type that encompasses (2) associated Types (row and column)
package io.semiotics.type.grid;
import java.io.Serializable;
import java.util.HashSet;
import java.util.Set;
import io.semiotics.data.Word;
import io.semiotics.type.InvalidBin;
import io.semiotics.type.InvalidForm;
import io.semiotics.type.MultiPartForm.ObjectArrayDomain;
@edefazio
edefazio / codestyle.EricSpacing_No_Comments.java
Created February 29, 2016 01:42
Eric's Coding Style trying to make Java code more readable at a glance, and in focussed detail
package codestyle;
public class EricSpacing_No_Comments
{
public static int a = 0;
public static int b = 0;
public static int c = 0;
public static int d = 0;
public static int e = 0;
public static int s = 0;