Last Update 2026/08/17
低スペック寄りのPCでローカルLLMを動作させた際の記録です。
LLM以外の仮想マシンなどが起動され、多少負荷がかかった状態で実行しています。
ベンチマークなどでLLMの性能を評価する内容ではありません。
LLM以外の仮想マシンなどが起動され、多少負荷がかかった状態で実行しています。
ベンチマークなどでLLMの性能を評価する内容ではありません。
検証用PC
|
OS |
Debian GNU/Linux 12 (bookworm) |
|
CPU |
Intel(R) Core(TM) i5-14400F |
|
GPU |
GeForce RTX 3060 12GB |
|
メモリ |
DDR4 PC4-25600 32GB × 4 |
|
SSD |
crucial P310 CT1000P310SSD8-JP |
構築環境 : Docker + Ollama (特別な設定などは無い状態)
検証用プロンプト
```
### 依頼内容
- コード生成
### 指示
- C言語
- コード以外の出力は不要
- 中括弧スタイルはオールマン
- テストコードも生成
- テストコードは別ファイル
- 実行用ソースファイル名 : sample_code.c
- テスト用ソースファイル名 : sample_test.c
- 標準ヘッダ以外は使用しない
- 戻り値はEXIT_SUCCESSを使用
- 関数はmain()の前で定義
### コード仕様(sample_code.c)
- コマンドラインから整数2つを取得
- [引数1]から[引数2]までをインクリメントして空白区切りで標準出力に出力
- 出力する文字列はmain()ではなく関数で生成
### コード仕様(sample_test.c)
- unity.hを使用しない
```
モデル詳細
Model
architecture laguna
parameters 117.6B
context length 262144
embedding length 3072
quantization Q8_0
Capabilities
completion
tools
thinking
Laguna S 2.1 (GPU無) [実測結果一覧へ]
(1) temperature=---; top_p=---; top_k=--
2026-08-12
total duration: 4m21.380088684s
load duration: 1m33.840505078s
prompt eval count: 322 token(s)
prompt eval duration: 13.769845s
prompt eval rate: 23.38 tokens/s
eval count: 718 token(s)
eval duration: 2m33.622064s
eval rate: 4.67 tokens/s
(GPU無)
コード生成結果の概要
・C言語による生成
・コード以外の出力無し
・コードの記述スタイルをオールマンで生成
・戻り値は stdlib.h の EXIT_*** を使用
・文字列生成関数
メモリの確保はmain()側
start > end の場合はステップは-1
インクリメント+空白区切りで文字列用メモリに書き込み
文字列用メモリへのポインタを返す
・main()
引数個数のチェック(エラー処理有)
文字列長に応じたメモリの確保
文字列生成関数の呼び出し
・テストコードを別途生成
実行用コードと同一の文字列生成関数定義を記述
main()を伴うテストコード
文字列生成関数を5種類の引数の組み合わせでテスト実行
(1) 整数1 < 整数2
(2) 整数1 > 整数2
(3) 整数1 == 整数2
(4) 整数1 < 整数2 ただし、整数1が負数
(5) 整数1 > 整数2 ただし、整数1が負数
(注) LLMの生成結果は毎回一定ではないため、結果によっては上記内容通りではないことが考えられます。
生成コードの実行結果
sample_code.c : 検証用プロンプトにて生成されたコードsample_test.c : 生成されたテストコード
$ gcc -Wall -o sample_code sample_code.c
sample_code.c: In function ‘generate_range’:
sample_code.c:41:13: warning: ‘sprintf’ argument 3 overlaps destination object ‘output’ [-Wrestrict]
41 | sprintf(output, "%s%d ", output, i);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
sample_code.c:28:47: note: destination object referenced by ‘restrict’-qualified argument 1 was declared here
28 | void generate_range(int start, int end, char *output)
| ~~~~~~^~~~~~
sample_code.c:34:13: warning: ‘sprintf’ argument 3 overlaps destination object ‘output’ [-Wrestrict]
34 | sprintf(output, "%s%d ", output, i);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
sample_code.c:28:47: note: destination object referenced by ‘restrict’-qualified argument 1 was declared here
28 | void generate_range(int start, int end, char *output)
| ~~~~~~^~~~~~
$ gcc -Wall -o sample_test sample_test.c
sample_test.c:6:5: error: conflicting types for ‘main’; have ‘int(void)’
6 | int main(void)
| ^~~~
In file included from sample_test.c:4:
sample_code.c:6:5: note: previous definition of ‘main’ with type ‘int(int, char **)’
6 | int main(int argc, char *argv[])
| ^~~~
$ vi sample_code.c ← main()関数重複エラー解消のため条件付きコンパイル用の#ifndefマクロを追加
$ gcc -D TEST_MAIN -Wall -o sample_test sample_test.c
In file included from sample_test.c:4:
sample_code.c: In function ‘generate_range’:
sample_code.c:43:13: warning: ‘sprintf’ argument 3 overlaps destination object ‘output’ [-Wrestrict]
43 | sprintf(output, "%s%d ", output, i);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
sample_code.c:30:47: note: destination object referenced by ‘restrict’-qualified argument 1 was declared here
30 | void generate_range(int start, int end, char *output)
| ~~~~~~^~~~~~
sample_code.c:36:13: warning: ‘sprintf’ argument 3 overlaps destination object ‘output’ [-Wrestrict]
36 | sprintf(output, "%s%d ", output, i);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
sample_code.c:30:47: note: destination object referenced by ‘restrict’-qualified argument 1 was declared here
30 | void generate_range(int start, int end, char *output)
| ~~~~~~^~~~~~
$ ./sample_code 1 5
1 2 3 4 5
$ ./sample_code -3 3
-3 -2 -1 0 1 2 3
$ ./sample_code 1 1
1
$ ./sample_code 5 1
5 4 3 2 1
$ ./sample_test
All tests passed!
(2) temperature=---; top_p=---; top_k=--
2026-08-12
total duration: 3m7.547332478s
load duration: 123.893857ms
prompt eval count: 275 token(s)
prompt eval duration: 12.426869s
prompt eval rate: 22.13 tokens/s
eval count: 829 token(s)
eval duration: 2m54.878021s
eval rate: 4.74 tokens/s
(GPU無)
コード生成結果の概要
・C言語による生成
・コード以外の出力無し
・メインコードのみ記述スタイルをオールマンで生成
・戻り値は stdlib.h の EXIT_*** を使用
・文字列生成関数
文字列生成ではなく出力
・main()
引数個数のチェック(エラー処理有)
文字列生成関数の呼び出し
・テストコードを別途生成
テスト対象関数の宣言
main()を伴うテストコード
GCCによるコードのコンパイルを伴うpopen()関数の記述
文字列生成関数を5種類の引数の組み合わせでテスト実行
(1) 整数1 < 整数2
(2) 整数1 == 整数2
(3) 整数1 > 整数2
(4) 整数1 < 整数2 ただし、整数1が負数
(注) LLMの生成結果は毎回一定ではないため、結果によっては上記内容通りではないことが考えられます。
生成コードの実行結果
sample_code.c : 検証用プロンプトにて生成されたコードsample_test.c : 生成されたテストコード
$ gcc -Wall -o sample_code sample_code.c
$ gcc -Wall -o sample_test sample_code.c sample_test.c
sample_test.c: In function ‘main’:
sample_test.c:11:10: warning: unused variable ‘path’ [-Wunused-variable]
11 | char path[1024];
| ^~~~
/bin/ld: /tmp/ccez5M03.o: in function `main':
sample_test.c:(.text+0x0): multiple definition of `main'; /tmp/ccR3RkHI.o:sample_code.c:(.text+0x0): first defined here
collect2: error: ld returned 1 exit status
$ vi sample_code.c ← main()関数重複エラー解消のため条件付きコンパイル用の#ifndefマクロを追加
$ gcc -D TEST_MAIN -Wall -o sample_test sample_code.c sample_test.c
sample_test.c: In function ‘main’:
sample_test.c:11:10: warning: unused variable ‘path’ [-Wunused-variable]
11 | char path[1024];
| ^~~~
$ ./sample_code 1 5
1 2 3 4 5
$ ./sample_code -3 3
-3 -2 -1 0 1 2 3
$ ./sample_code 1 1
1
$ ./sample_code 5 1
$ ./sample_test
All tests passed!
(3) temperature=0.70; top_p=0.7; top_k=--
2026-08-12
total duration: 1m14.82504503s
load duration: 112.488083ms
prompt eval count: 275 token(s)
prompt eval duration: 584.77ms
prompt eval rate: 470.27 tokens/s
eval count: 363 token(s)
eval duration: 1m14.089554s
eval rate: 4.90 tokens/s
(GPU無)
コード生成結果の概要
・C言語による生成
・コード以外の出力無し
・コードの記述スタイルをオールマンで生成
・戻り値は stdlib.h の EXIT_*** を使用
・文字列生成関数
文字列生成ではなく出力
・main()
引数個数のチェック(エラー処理有)
文字列生成関数の呼び出し
・テストコードを別途生成
テスト対象関数の宣言
main()を伴うテストコード
文字列生成関数を5種類の引数の組み合わせでテスト実行
(1) 整数1 < 整数2
(2) 整数1 == 整数2
(3) 整数1 < 整数2 ただし、整数1が負数
(注) LLMの生成結果は毎回一定ではないため、結果によっては上記内容通りではないことが考えられます。
生成コードの実行結果
sample_code.c : 検証用プロンプトにて生成されたコードsample_test.c : 生成されたテストコード
$ gcc -Wall -o sample_code sample_code.c
$ gcc -Wall -o sample_test sample_code.c sample_test.c
/bin/ld: /tmp/ccUDHr5X.o: in function `main':
sample_test.c:(.text+0x61): multiple definition of `main'; /tmp/ccdwbxSz.o:sample_code.c:(.text+0x0): first defined here
collect2: error: ld returned 1 exit status
$ vi sample_code.c ← main()関数重複エラー解消のため条件付きコンパイル用の#ifndefマクロを追加
$ gcc -D TEST_MAIN -Wall -o sample_test sample_code.c sample_test.c
$ ./sample_code 1 5
1 2 3 4 5
$ ./sample_code -3 3
-3 -2 -1 0 1 2 3
$ ./sample_code 1 1
1
$ ./sample_code 5 1
$ ./sample_test
Test 1: Range from 1 to 5
1 2 3 4 5
Test 2: Range from 3 to 3
3
Test 3: Range from -2 to 2
-2 -1 0 1 2
(4) temperature=0.70; top_p=0.7; top_k=--
2026-08-12
total duration: 2m58.359658193s
load duration: 102.333383ms
prompt eval count: 264 token(s)
prompt eval duration: 10.916385s
prompt eval rate: 24.18 tokens/s
eval count: 799 token(s)
eval duration: 2m47.289359s
eval rate: 4.78 tokens/s
(GPU無)
コード生成結果の概要
・C言語による生成
・コード以外の出力無し
・コードの記述スタイルをオールマンで生成
・戻り値は stdlib.h の EXIT_*** を使用
・文字列生成関数
文字列生成ではなく出力
・main()
引数個数のチェック(エラー処理有)
文字列生成関数の呼び出し
・テストコードを別途生成
テスト対象関数の宣言
main()を伴うテストコード
標準出力を仮ファイルにリダイレクト
文字列生成関数を5種類の引数の組み合わせでテスト実行
(1) 整数1 < 整数2
(2) 整数1 == 整数2
(3) 整数1 < 整数2 ただし、整数1が負数
(注) LLMの生成結果は毎回一定ではないため、結果によっては上記内容通りではないことが考えられます。
生成コードの実行結果
sample_code.c : 検証用プロンプトにて生成されたコードsample_test.c : 生成されたテストコード
$ gcc -Wall -o sample_code sample_code.c
$ gcc -Wall -o sample_test sample_code.c sample_test.c
/bin/ld: /tmp/ccRP3Wma.o: in function `main':
sample_test.c:(.text+0x2e3): multiple definition of `main'; /tmp/ccuR65gd.o:sample_code.c:(.text+0x0): first defined here
collect2: error: ld returned 1 exit status
$ vi sample_code.c ← main()関数重複エラー解消のため条件付きコンパイル用の#ifndefマクロを追加
$ gcc -D TEST_MAIN -Wall -o sample_test sample_code.c sample_test.c
$ ./sample_code 1 5
1 2 3 4 5
$ ./sample_code -3 3
-3 -2 -1 0 1 2 3
$ ./sample_code 1 1
1
$ ./sample_code 5 1
$ ./sample_test ← stdoutがリダイレクトから戻されていないため何も表示されない
$ vi sample_test.c ← freopen("/dev/tty", "w", stdout) を追加
$ gcc -D TEST_MAIN -Wall -o sample_test sample_code.c sample_test.c
$ ./sample_test
Test case 1 passed: Normal range output is correct.
Test case 2 passed: Single value output is correct.
Test case 3 passed: Negative range output is correct.
(5) temperature=0.50; top_p=0.7; top_k=--
2026-08-12
total duration: 2m18.528978224s
load duration: 127.815442ms
prompt eval count: 275 token(s)
prompt eval duration: 594.691ms
prompt eval rate: 462.43 tokens/s
eval count: 666 token(s)
eval duration: 2m17.759198s
eval rate: 4.83 tokens/s
(GPU無)
コード生成結果の概要
・C言語による生成
・コード以外の出力無し
・コードの記述スタイルをオールマンで生成
・戻り値は stdlib.h の EXIT_*** を使用
・文字列生成関数
文字列生成ではなく出力
・main()
引数個数のチェック(エラー処理有)
文字列生成関数の呼び出し
・テストコードを別途生成
テスト対象関数の宣言
main()を伴うテストコード
標準出力を仮ファイルにリダイレクト
文字列生成関数を5種類の引数の組み合わせでテスト実行
(1) 整数1 < 整数2
(2) 整数1 == 整数2
(3) 整数1 < 整数2 ただし、整数1が負数
(注) LLMの生成結果は毎回一定ではないため、結果によっては上記内容通りではないことが考えられます。
生成コードの実行結果
sample_code.c : 検証用プロンプトにて生成されたコードsample_test.c : 生成されたテストコード
$ gcc -Wall -o sample_code sample_code.c
$ gcc -Wall -o sample_test sample_code.c sample_test.c
/bin/ld: /tmp/ccxbrXB5.o: in function `main':
sample_test.c:(.text+0x0): multiple definition of `main'; /tmp/ccRqMc17.o:sample_code.c:(.text+0x0): first defined here
collect2: error: ld returned 1 exit status
$ vi sample_code.c ← main()関数重複エラー解消のため条件付きコンパイル用の#ifndefマクロを追加
$ gcc -D TEST_MAIN -Wall -o sample_test sample_code.c sample_test.c
$ ./sample_code 1 5
1 2 3 4 5
$ ./sample_code -3 3
-3 -2 -1 0 1 2 3
$ ./sample_code 1 1
1
$ ./sample_code 5 1
$ ./sample_test ← stdoutがリダイレクトから戻されていないため何も表示されない
$ vi sample_test.c ← freopen("/dev/tty", "w", stdout) を追加
$ gcc -D TEST_MAIN -Wall -o sample_test sample_code.c sample_test.c
$ ./sample_test
Test case 1 passed.
Test case 2 passed.
Test case 3 passed.
(6) temperature=0.30; top_p=0.7; top_k=--
2026-08-12
total duration: 1m39.710318442s
load duration: 98.006915ms
prompt eval count: 275 token(s)
prompt eval duration: 584.276ms
prompt eval rate: 470.67 tokens/s
eval count: 484 token(s)
eval duration: 1m38.978868s
eval rate: 4.89 tokens/s
(GPU無)
コード生成結果の概要
・C言語による生成
・コード以外の出力無し
・コードの記述スタイルをオールマンで生成
・戻り値は stdlib.h の EXIT_*** を使用
・文字列生成関数
文字列生成ではなく出力
・main()
引数個数のチェック(エラー処理有)
文字列生成関数の呼び出し
・テストコードを別途生成
テスト対象関数の宣言
main()を伴うテストコード
標準出力を仮ファイルにリダイレクト
文字列生成関数を1ケースのみテスト実行
(1) 整数1 < 整数2
(注) LLMの生成結果は毎回一定ではないため、結果によっては上記内容通りではないことが考えられます。
生成コードの実行結果
sample_code.c : 検証用プロンプトにて生成されたコードsample_test.c : 生成されたテストコード
$ gcc -Wall -o sample_code sample_code.c
$ gcc -Wall -o sample_test sample_code.c sample_test.c
sample_test.c: In function ‘test_generate_sequence’:
sample_test.c:11:29: warning: initialization of ‘FILE *’ from ‘int’ makes pointer from integer without a cast [-Wint-conversion]
11 | FILE *original_stdout = dup(fileno(stdout));
| ^~~
sample_test.c:19:21: warning: passing argument 1 of ‘fdopen’ makes integer from pointer without a cast [-Wint-conversion]
19 | stdout = fdopen(original_stdout, "w");
| ^~~~~~~~~~~~~~~
| |
| FILE *
In file included from sample_test.c:1:
/usr/include/stdio.h:299:26: note: expected ‘int’ but argument is of type ‘FILE *’
299 | extern FILE *fdopen (int __fd, const char *__modes) __THROW
| ~~~~^~~~
/bin/ld: /tmp/ccCW3iTX.o: in function `main':
sample_test.c:(.text+0x189): multiple definition of `main'; /tmp/ccYhCju8.o:sample_code.c:(.text+0x0): first defined here
collect2: error: ld returned 1 exit status
$ vi sample_code.c ← main()関数重複エラー解消のため条件付きコンパイル用の#ifndefマクロを追加
$ gcc -D TEST_MAIN -Wall -o sample_test sample_code.c sample_test.c
sample_test.c: In function ‘test_generate_sequence’:
sample_test.c:11:29: warning: initialization of ‘FILE *’ from ‘int’ makes pointer from integer without a cast [-Wint-conversion]
11 | FILE *original_stdout = dup(fileno(stdout));
| ^~~
sample_test.c:19:21: warning: passing argument 1 of ‘fdopen’ makes integer from pointer without a cast [-Wint-conversion]
19 | stdout = fdopen(original_stdout, "w");
| ^~~~~~~~~~~~~~~
| |
| FILE *
In file included from sample_test.c:1:
/usr/include/stdio.h:299:26: note: expected ‘int’ but argument is of type ‘FILE *’
299 | extern FILE *fdopen (int __fd, const char *__modes) __THROW
| ~~~~^~~~
$ ./sample_code 1 5
1 2 3 4 5
$ ./sample_code -3 3
-3 -2 -1 0 1 2 3
$ ./sample_code 1 1
1
$ ./sample_code 5 1
$ ./sample_test
Test passed: generate_sequence(3, 7)
(7) temperature=0.15; top_p=---; top_k=--
2026-08-12
total duration: 3m26.948098325s
load duration: 120.457642ms
prompt eval count: 275 token(s)
prompt eval duration: 595.635ms
prompt eval rate: 461.69 tokens/s
eval count: 978 token(s)
eval duration: 3m26.187042s
eval rate: 4.74 tokens/s
(GPU無)
コード生成結果の概要
・C言語による生成
・コード以外の出力無し
・コードの記述スタイルをオールマンで生成
・戻り値は stdlib.h の EXIT_*** を使用
・文字列生成関数
文字列生成ではなく出力
・main()
引数個数のチェック(エラー処理有)
文字列生成関数の呼び出し
・テストコードを別途生成
main()を伴うテストコード
popen()を使用して関数を外部コードとして実行
文字列生成関数を3種類の引数の組み合わせでテスト実行
(1) 整数1 < 整数2
(2) 整数1 == 整数2
(3) 整数1 < 整数2 ただし、整数1が負数
(注) LLMの生成結果は毎回一定ではないため、結果によっては上記内容通りではないことが考えられます。
生成コードの実行結果
sample_code.c : 検証用プロンプトにて生成されたコードsample_test.c : 生成されたテストコード
$ gcc -Wall -o sample_code sample_code.c
$ gcc -Wall -o sample_test sample_test.c
$ ./sample_code 1 5
1 2 3 4 5
$ ./sample_code -3 3
-3 -2 -1 0 1 2 3
$ ./sample_code 1 1
1
$ ./sample_code 5 1
$ ./sample_test
Test 1 PASSED
Test 2 PASSED
Test 3 PASSED
All tests PASSED!
(8) temperature=0.15; top_p=0.7; top_k=--
2026-08-12
total duration: 1m45.994687509s
load duration: 111.864575ms
prompt eval count: 275 token(s)
prompt eval duration: 586.252ms
prompt eval rate: 469.08 tokens/s
eval count: 513 token(s)
eval duration: 1m45.248046s
eval rate: 4.87 tokens/s
(GPU無)
コード生成結果の概要
・C言語による生成
・コード以外の出力無し
・コードの記述スタイルをオールマンで生成
・戻り値は stdlib.h の EXIT_*** を使用
・文字列生成関数
文字列生成ではなく出力
・main()
引数個数のチェック(エラー処理有)
文字列生成関数の呼び出し
・テストコードを別途生成
main()を伴うテストコード
標準出力を仮ファイルにリダイレクト
文字列生成関数を1ケースのみテスト実行
(1) 整数1 < 整数2
(注) LLMの生成結果は毎回一定ではないため、結果によっては上記内容通りではないことが考えられます。
生成コードの実行結果
sample_code.c : 検証用プロンプトにて生成されたコードsample_test.c : 生成されたテストコード
$ gcc -Wall -o sample_code sample_code.c
$ gcc -Wall -o sample_test sample_code.c sample_test.c
sample_test.c: In function ‘test_generate_sequence’:
sample_test.c:11:29: warning: initialization of ‘FILE *’ from ‘int’ makes pointer from integer without a cast [-Wint-conversion]
11 | FILE *original_stdout = dup(fileno(stdout));
| ^~~
sample_test.c:19:10: warning: passing argument 1 of ‘dup2’ makes integer from pointer without a cast [-Wint-conversion]
19 | dup2(original_stdout, fileno(stdout));
| ^~~~~~~~~~~~~~~
| |
| FILE *
In file included from sample_test.c:4:
/usr/include/unistd.h:555:22: note: expected ‘int’ but argument is of type ‘FILE *’
555 | extern int dup2 (int __fd, int __fd2) __THROW;
| ~~~~^~~~
sample_test.c:20:11: warning: passing argument 1 of ‘close’ makes integer from pointer without a cast [-Wint-conversion]
20 | close(original_stdout);
| ^~~~~~~~~~~~~~~
| |
| FILE *
/usr/include/unistd.h:358:23: note: expected ‘int’ but argument is of type ‘FILE *’
358 | extern int close (int __fd);
| ~~~~^~~~
/bin/ld: /tmp/cc2lePjq.o: in function `main':
sample_test.c:(.text+0x19c): multiple definition of `main'; /tmp/cc1v4pRf.o:sample_code.c:(.text+0x0): first defined here
collect2: error: ld returned 1 exit status
$ vi sample_code.c ← main()関数重複エラー解消のため条件付きコンパイル用の#ifndefマクロを追加
$ gcc -D TEST_MAIN -Wall -o sample_test sample_code.c sample_test.c
sample_test.c: In function ‘test_generate_sequence’:
sample_test.c:11:29: warning: initialization of ‘FILE *’ from ‘int’ makes pointer from integer without a cast [-Wint-conversion]
11 | FILE *original_stdout = dup(fileno(stdout));
| ^~~
sample_test.c:19:10: warning: passing argument 1 of ‘dup2’ makes integer from pointer without a cast [-Wint-conversion]
19 | dup2(original_stdout, fileno(stdout));
| ^~~~~~~~~~~~~~~
| |
| FILE *
In file included from sample_test.c:4:
/usr/include/unistd.h:555:22: note: expected ‘int’ but argument is of type ‘FILE *’
555 | extern int dup2 (int __fd, int __fd2) __THROW;
| ~~~~^~~~
sample_test.c:20:11: warning: passing argument 1 of ‘close’ makes integer from pointer without a cast [-Wint-conversion]
20 | close(original_stdout);
| ^~~~~~~~~~~~~~~
| |
| FILE *
/usr/include/unistd.h:358:23: note: expected ‘int’ but argument is of type ‘FILE *’
358 | extern int close (int __fd);
| ~~~~^~~~
$ ./sample_code 1 5
1 2 3 4 5
$ ./sample_code -3 3
-3 -2 -1 0 1 2 3
$ ./sample_code 1 1
1
$ ./sample_code 5 1
$ ./sample_test ← stdoutのリダイレクトに関して不具合があり、結果が表示されない
$ vi sample_test.c ← fclose(stdout)の削除とfflush(stdout)の追加
$ gcc -D TEST_MAIN -Wall -o sample_test sample_code.c sample_test.c
sample_test.c: In function ‘test_generate_sequence’:
sample_test.c:11:29: warning: initialization of ‘FILE *’ from ‘int’ makes pointer from integer without a cast [-Wint-conversion]
11 | FILE *original_stdout = dup(fileno(stdout));
| ^~~
sample_test.c:20:10: warning: passing argument 1 of ‘dup2’ makes integer from pointer without a cast [-Wint-conversion]
20 | dup2(original_stdout, fileno(stdout));
| ^~~~~~~~~~~~~~~
| |
| FILE *
In file included from sample_test.c:4:
/usr/include/unistd.h:555:22: note: expected ‘int’ but argument is of type ‘FILE *’
555 | extern int dup2 (int __fd, int __fd2) __THROW;
| ~~~~^~~~
sample_test.c:21:11: warning: passing argument 1 of ‘close’ makes integer from pointer without a cast [-Wint-conversion]
21 | close(original_stdout);
| ^~~~~~~~~~~~~~~
| |
| FILE *
/usr/include/unistd.h:358:23: note: expected ‘int’ but argument is of type ‘FILE *’
358 | extern int close (int __fd);
| ~~~~^~~~
$ ./sample_test
Test passed: Output matches expected value
(9) temperature=0.15; top_p=0.5; top_k=--
2026-08-12
total duration: 3m26.488898389s
load duration: 121.603521ms
prompt eval count: 275 token(s)
prompt eval duration: 601.047ms
prompt eval rate: 457.53 tokens/s
eval count: 978 token(s)
eval duration: 3m25.718727s
eval rate: 4.75 tokens/s
(GPU無)
コード生成結果の概要
・C言語による生成
・コード以外の出力無し
・コードの記述スタイルをオールマンで生成
・戻り値は stdlib.h の EXIT_*** を使用
・文字列生成関数
文字列生成ではなく出力
・main()
引数個数のチェック(エラー処理有)
文字列生成関数の呼び出し
・テストコードを別途生成
main()を伴うテストコード
popen()を使用して関数を外部コードとして実行
文字列生成関数を3種類の引数の組み合わせでテスト実行
(1) 整数1 < 整数2
(2) 整数1 == 整数2
(3) 整数1 < 整数2 ただし、整数1が負数
(注) LLMの生成結果は毎回一定ではないため、結果によっては上記内容通りではないことが考えられます。
生成コードの実行結果
sample_code.c : 検証用プロンプトにて生成されたコードsample_test.c : 生成されたテストコード
$ gcc -Wall -o sample_code sample_code.c
$ gcc -Wall -o sample_test sample_test.c
$ ./sample_code 1 5
1 2 3 4 5
$ ./sample_code -3 3
-3 -2 -1 0 1 2 3
$ ./sample_code 1 1
1
$ ./sample_code 5 1
$ ./sample_test
Test 1 PASSED
Test 2 PASSED
Test 3 PASSED
All tests PASSED!
(10) temperature=0.15; top_p=0.4; top_k=--
2026-08-12
total duration: 3m5.930586615s
load duration: 132.556881ms
prompt eval count: 275 token(s)
prompt eval duration: 598.994ms
prompt eval rate: 459.10 tokens/s
eval count: 879 token(s)
eval duration: 3m5.134477s
eval rate: 4.75 tokens/s
(GPU無)
コード生成結果の概要
・C言語による生成
・コード以外の出力無し
・コードの記述スタイルをオールマンで生成
・戻り値は stdlib.h の EXIT_*** を使用
・文字列生成関数
文字列生成ではなく出力
・main()
引数個数のチェック(エラー処理有)
文字列生成関数の呼び出し
・テストコードを別途生成
main()を伴うテストコード
popen()を使用して関数を外部コードとして実行
文字列生成関数を3種類の引数の組み合わせでテスト実行
(1) 整数1 < 整数2
(2) 整数1 == 整数2
(3) 整数1 < 整数2 ただし、整数1が負数
(注) LLMの生成結果は毎回一定ではないため、結果によっては上記内容通りではないことが考えられます。
生成コードの実行結果
sample_code.c : 検証用プロンプトにて生成されたコードsample_test.c : 生成されたテストコード
$ gcc -Wall -o sample_code sample_code.c
$ gcc -Wall -o sample_test sample_test.c
$ ./sample_code 1 5
1 2 3 4 5
$ ./sample_code -3 3
-3 -2 -1 0 1 2 3
$ ./sample_code 1 1
1
$ ./sample_code 5 1
$ ./sample_test
Test 1 PASSED
Test 2 PASSED
Test 3 PASSED
All tests PASSED
(11) temperature=0.15; top_p=0.7; top_k=32
2026-08-12
total duration: 3m12.714484359s
load duration: 111.243778ms
prompt eval count: 275 token(s)
prompt eval duration: 614.132ms
prompt eval rate: 447.79 tokens/s
eval count: 910 token(s)
eval duration: 3m11.916888s
eval rate: 4.74 tokens/s
(GPU無)
コード生成結果の概要
・C言語による生成
・コード以外の出力無し
・コードの記述スタイルがsample_code.cのみオールマンスタイル
・戻り値は stdlib.h の EXIT_*** を使用
・文字列生成関数
文字列生成ではなく出力
・main()
引数個数のチェック(エラー処理有)
文字列生成関数の呼び出し
・テストコードを別途生成
main()を伴うテストコード
popen()を使用して関数を外部コードとして実行
文字列生成関数を3種類の引数の組み合わせでテスト実行
(1) 整数1 < 整数2
(2) 整数1 == 整数2
(3) 整数1 < 整数2 ただし、整数1が負数
(注) LLMの生成結果は毎回一定ではないため、結果によっては上記内容通りではないことが考えられます。
生成コードの実行結果
sample_code.c : 検証用プロンプトにて生成されたコードsample_test.c : 生成されたテストコード
$ gcc -Wall -o sample_code sample_code.c
$ gcc -Wall -o sample_test sample_test.c
$ ./sample_code 1 5
1 2 3 4 5
$ ./sample_code -3 3
-3 -2 -1 0 1 2 3
$ ./sample_code 1 1
1
$ ./sample_code 5 1
$ ./sample_test
Test passed: Normal sequence
Test passed: Single number
Test passed: Negative numbers
All tests passed!
(12) temperature=0.15; top_p=0.7; top_k=16
2026-08-12
total duration: 4m2.15038459s
load duration: 90.822321ms
prompt eval count: 275 token(s)
prompt eval duration: 593.343ms
prompt eval rate: 463.48 tokens/s
eval count: 1131 token(s)
eval duration: 4m1.380624s
eval rate: 4.69 tokens/s
(GPU無)
コード生成結果の概要
・C言語による生成
・コード以外の出力無し
・コードの記述スタイルをオールマンで生成
・戻り値は stdlib.h の EXIT_*** を使用
・文字列生成関数
文字列生成ではなく出力
・main()
引数個数のチェック(エラー処理有)
文字列生成関数の呼び出し
・テストコードを別途生成
main()を伴うテストコード
popen()を使用して関数を外部コードとして実行
文字列生成関数を4種類の引数の組み合わせでテスト実行
(1) 整数1 < 整数2
(2) 整数1 == 整数2
(3) 整数1 < 整数2 ただし、整数1が負数
(4) 整数1 のみ
(注) LLMの生成結果は毎回一定ではないため、結果によっては上記内容通りではないことが考えられます。
生成コードの実行結果
sample_code.c : 検証用プロンプトにて生成されたコードsample_test.c : 生成されたテストコード
$ gcc -Wall -o sample_code sample_code.c
$ gcc -Wall -o sample_test sample_test.c
$ ./sample_code 1 5
1 2 3 4 5
$ ./sample_code -3 3
-3 -2 -1 0 1 2 3
$ ./sample_code 1 1
1
$ ./sample_code 5 1
$ ./sample_test
Test 1 PASSED
Test 2 PASSED
Test 3 PASSED
Usage: ./sample_code <start> <end>
Test 4 PASSED
All tests passed!
(13) temperature=0.10; top_p=0.7; top_k=--
2026-08-12
total duration: 33m51.812509241s
load duration: 123.651789ms
prompt eval count: 277 token(s)
prompt eval duration: 11.405665s
prompt eval rate: 24.29 tokens/s
eval count: 7480 token(s)
eval duration: 33m40.203251s
eval rate: 3.70 tokens/s
(GPU無)
コード生成結果の概要
・C言語による生成
・コード以外の出力無し
・コードの記述スタイルのオールマン指定を無視
・戻り値は stdlib.h の EXIT_*** を使用
・文字列生成関数
start > end の場合はNULL文字のみのメモリへのポインタを返す
文字列長に応じたメモリの確保(エラー処理有)
インクリメント+空白区切りで文字列用メモリに書き込み
文字列用メモリへのポインタを返す
・main()
引数個数のチェック(エラー処理有)
文字列生成関数の呼び出し(エラー処理有)
生成文字列の標準出力への出力
文字列用メモリの解放
・テストコードを別途生成
main()を伴うテストコード
文字列生成関数を4種類の引数の組み合わせでテスト実行
(1) 整数1 < 整数2
(2) 整数1 == 整数2
(3) 整数1 > 整数2
(4) 整数1 < 整数2 ただし、整数1が負数、整数2が0
(5) 整数1 < 整数2 ただし、全て整数は2桁以上
(6) 整数1 < 整数2 ただし、整数1が0
(7) 整数1 == 整数2 ただし、整数1、整数2が負数
(8) 整数1 < 整数2 ただし、出力文字列の構成整数が4個
(注) LLMの生成結果は毎回一定ではないため、結果によっては上記内容通りではないことが考えられます。
生成コードの実行結果
sample_code.c : 検証用プロンプトにて生成されたコードsample_test.c : 生成されたテストコード
$ gcc -Wall -o sample_code sample_code.c
$ gcc -Wall -o sample_test sample_code.c sample_test.c
/bin/ld: /tmp/ccyScJPj.o: in function `main':
sample_test.c:(.text+0x354): multiple definition of `main'; /tmp/ccqlwgfu.o:sample_code.c:(.text+0x18b): first defined here
collect2: error: ld returned 1 exit status
$ vi sample_code.c
$ gcc -D TEST_MAIN -Wall -o sample_test sample_code.c sample_test.c
$ ./sample_code 1 5
1 2 3 4 5
$ ./sample_code -3 3
-3 -2 -1 0 1 2 3
$ ./sample_code 1 1
1
$ ./sample_code 5 1
$ ./sample_test
All tests passed.