Skip to content

Instantly share code, notes, and snippets.

Konstantin Const-me

View GitHub Profile
View SinCosAngle.cpp
#define _USE_MATH_DEFINES
#include <math.h>
struct Point
{
double x, y;
};
// A class that contains a 2D angle as a pair of sine + cosine values.
// Sometimes, this approach saves substantial CPU time that would be wasted running these trigonometry functions.
View set-count.cpp
#include <unordered_set>
#include <chrono>
using stopwatch = std::chrono::high_resolution_clock;
static const size_t count = 4 * 1024 * 1024;
void setup( std::unordered_set<size_t>& set )
{
srand( 0 );
for( size_t i = 0; i < count; i++ )
View ffx.cpp
#include "stdafx.h"
int f( int x )
{
if( 0 == x )
return 0;
if( 0x80000000 == x )
return 0x80000001;
const int c = ( ( x >> 31 ) & 1 ) * -2 + 1;
const int mul = ( x & 1 ) * 2 - 1;
@Const-me
Const-me / SinCosMicrobench.cpp
Created Jul 25, 2016
A benchmark comparing three methods of sine + cosine computation: stdlib, DirectX which is 10-11 degree polynomial approximation, and linearly-interpolated lookup table.
View SinCosMicrobench.cpp
#include "stdafx.h"
using std::vector;
typedef std::chrono::high_resolution_clock stopwatch;
using namespace DirectX;
using std::array;
struct StdLib
{
inline void sinCos( float val, float& s, float& c ) const
View Capstone.DisasmEx.cs
using Gee.External.Capstone;
using Gee.External.Capstone.X86;
using System;
using System.Collections.Generic;
using System.Linq;
namespace InstructionsCheck
{
/// <summary>This class implements a way to disassemble real-life modules with Capstone.</summary>
/// <remarks>Real-life x86 and amd64 code contains inline data.
You can’t perform that action at this time.