Skip to content

Commit

Permalink
📰docs: update
Browse files Browse the repository at this point in the history
  • Loading branch information
sharpchen committed Dec 31, 2023
1 parent 62e9902 commit 8397914
Show file tree
Hide file tree
Showing 13 changed files with 551 additions and 20 deletions.
66 changes: 66 additions & 0 deletions docs/document/Articles/docs/Integrating Cygwin with VSCode.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
# Integrating Cygwin with VSCode in Windows

## Installation

Follow guide from [Cygwin](https://cygwin.com/).

## Add terminal profile in `settings.json`

Add new profile for cygwin, this will register a new option when we choose to launch a new integrated terminal.

```json{15, 19}
{
"terminal.integrated.profiles.windows": {
"PowerShell": {
"source": "PowerShell",
"icon": "terminal-powershell"
},
"Command Prompt": {
"path": ["${env:windir}\\Sysnative\\cmd.exe", "${env:windir}\\System32\\cmd.exe"],
"args": [],
"icon": "terminal-cmd"
},
"Git Bash": {
"source": "Git Bash"
},
"Cygwin": {
"path": "C:\\cygwin64\\bin\\bash.exe",
"args": ["--login"],
"overrideName": true
}
},
}
```

Then we got a new option to create a integrated terminal.
![cygwin-option](../pics/cygwin-profile.png)

:::info
For more information: [Terminal Profiles](https://code.visualstudio.com/docs/terminal/profiles#_cygwin).
:::

## Change default working directory of cygwin in `.bashrc`

The default working directory of cygwin is `{installation-path}\home\{username}` like `C:\cygwin64\home\anon`.

You might like to launch cygwin with working directory as the root of current user.

- Open cygwin, make sure you're at `~`

```bash
cd ~
```

- Execute this line into `.bashrc`.

```bash
touch .bashrc && echo 'cd /cygdrive/c/users/{username}' >> .bashrc
```

- Check the content is successfully appended.

```bash
cat .bashrc
```

- Launch a new cygwin instance, it will start at your user root.
Binary file added docs/document/Articles/pics/cygwin-profile.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
# Init your cesium project with vite

## Create a latest vue3 project

Redirect to your working directory, run

```bash
pnpm create vue@latest
```

Follow the instruction, select options based on your need.(It's recommended to work with `typescript`, `vite` and `Vue Router`)

:::info
For more information: [Vue3 Tooling](https://vuejs.org/guide/scaling-up/tooling.html#project-scaffolding)
:::

## Add [cesium vite plugin](/~https://github.com/s3xysteak/vite-plugin-cesium-build)

```bash
pnpm add -D vite-plugin-cesium-build
```

```ts{9}
import { fileURLToPath, URL } from 'node:url';
import { defineConfig } from 'vite';
import vue from '@vitejs/plugin-vue';
import vueJsx from '@vitejs/plugin-vue-jsx';
import cesium from 'vite-plugin-cesium-build';
// https://vitejs.dev/config/
export default defineConfig({
plugins: [vue(), vueJsx(), cesium()],
resolve: {
alias: {
'@': fileURLToPath(new URL('./src', import.meta.url))
}
}
});
```

## Add a earth at `App.vue`

Delete auto-generated template, add following code.

```vue
<script setup lang="ts">
import { Viewer } from 'cesium';
import 'cesium/Build/Cesium/Widgets/widgets.css';
import { onMounted, ref, shallowRef } from 'vue';
const cesium = ref<Element | null>(null);
const viewer = shallowRef<Viewer | null>(null);
onMounted(() => {
viewer.value = new Viewer(cesium.value as Element);
});
</script>
<template>
<div ref="cesium" style="height: 100vh; width: 100vw"></div>
</template>
<style scoped></style>
```

Start the server.

```bash
pnpm dev
```

:::warning
Check scripts in `package.json` to make sure you use the right command, auto-generated scripts might differ from versions.
:::
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<LangVersion>preview</LangVersion>
<Configuration>Release</Configuration>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="BenchmarkDotNet" Version="0.13.11" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.5.0" />
<PackageReference Include="xunit" Version="2.4.2" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.5">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,96 @@
using CSharpDesignPatternsDemo.Structural;
using CSharpDesignPatternsDemo.Creational;
using System.Numerics;
using System.Text.Json;
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Running;
using BenchmarkDotNet.Configs;
using BenchmarkDotNet.Validators;
using BenchmarkDotNet.Loggers;
using BenchmarkDotNet.Columns;

var p1 = 20 + 30.Percentage();
var p2 = 2 - 50f.Percentage();
var p3 = 4 * 25d.Percentage();
var p4 = 1 / 66m.Percentage();
var p11 = 30.Percentage() + 20;
var p12 = 2f.Percentage() - 50;
var p13 = 4d.Percentage() * 25;
var p14 = 1m.Percentage() / 66;
Print(p1, p2, p3, p4, p11, p12, p13, p14);
// var enemyCollection = EnemyCollection.Create(10, () => (Random.Shared.Next(18, 36), Random.Shared.NextDouble()));
// Magic.Freeze(enemyCollection);
// enemyCollection[2].Agility = 250;
// Console.WriteLine(enemyCollection._agility![2]);
// var enemies = new EnemySpan(5, () => (1, 2));
// foreach (ref var e in enemies.Agility)
// {
// e = 250;
// }
// foreach (var e in enemies._agility!)
// {
// Console.WriteLine(e);
// }

static void Print(params object[] objects)
{
objects.ToList().ForEach(Console.WriteLine);
}
var config = new ManualConfig()
.WithOptions(ConfigOptions.DisableOptimizationsValidator)
.AddValidator(JitOptimizationsValidator.DontFailOnError)
.AddLogger(ConsoleLogger.Default)
.AddColumnProvider(DefaultColumnProviders.Instance);

BenchmarkRunner.Run<AoS_SoA>(config);

Span<int> span = Enumerable.Range(1, 100).ToArray().AsSpan();
Random.Shared.Shuffle(span);
var condition = span is [var first, _, .. var _]; // always true
condition.Out();
static class OutExtension
[MemoryDiagnoser]
public class AoS_SoA
{
public static void Out(this object o) => Console.WriteLine(o);
}
private Enemy[]? _aos;
private EnemyCollection? _soa;
private EnemyCollection2 _soaS;

private EnemySpan _soaSpan;
[Params(10000)] public int _size;

[GlobalSetup]
public void SetUp()
{
_aos = Enumerable.Range(1, _size)
.Select(x => new Enemy() { Age = Random.Shared.Next(18, 36), Agility = Random.Shared.NextDouble() })
.ToArray();
_soa = EnemyCollection.Create(_size, () => (Random.Shared.Next(18, 36), Random.Shared.NextDouble()));
_soaS = EnemyCollection2.Create(_size, () => (Random.Shared.Next(18, 36), Random.Shared.NextDouble()));
_soaSpan = new(_size, () => (Random.Shared.Next(18, 36), Random.Shared.NextDouble()));
}
[Benchmark]
public void Freeze_AoS()
{
for (int i = 0; i < _aos!.Length; i++)
{
ref Enemy e = ref _aos![i];
e.Agility = 0;
}
}
[Benchmark]
public void Freeze_SoA()
{
foreach (var e in _soa!)
{
e.Agility = 0;
}
}
[Benchmark]
public void Freeze_SoA_Enumerator()
{
var e = _soa!._agility!.GetEnumerator2();
while (e.MoveNext())
{
e.Current = 0;
}
}
[Benchmark]
public void Freeze_SoA_Struct()
{
foreach (var e in _soaS)
{
e.Agility = 0;
}
}
[Benchmark]
public void Freeze_SoA_Span()
{
foreach (ref var e in _soaSpan.Agility)
{
e = 0;
}
}
}
Loading

0 comments on commit 8397914

Please sign in to comment.