Last Update 2026/08/02
低スペック寄りの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 gemma4
parameters 31.3B
context length 262144
embedding length 5376
quantization Q4_K_M
requires 0.20.0
Capabilities
completion
vision
tools
thinking
Parameters
temperature 1
top_k 64
top_p 0.95
Gemma 4 [実測結果一覧へ]
(1) temperature=---; top_p=---; top_k=--
2026-07-29
total duration: 14m37.064254504s
load duration: 181.854009ms
prompt eval count: 205 token(s)
prompt eval duration: 1.18831396s
prompt eval rate: 172.51 tokens/s
eval count: 2906 token(s)
eval duration: 14m34.202950156s
eval rate: 3.32 tokens/s
コード生成結果の概要
・C言語による生成
・コード以外の出力無し
・コードの記述スタイルをオールマンで生成
・戻り値は stdlib.h の EXIT_*** を使用
・文字列生成関数
start > end の場合はNULL文字のみのメモリへのポインタを返す
文字列長に応じたメモリの確保(エラー処理有)
インクリメント+空白区切りで文字列用メモリに書き込み
文字列用メモリへのポインタを返す
・main()
引数個数のチェック(エラー処理有)
文字列生成関数の呼び出し(エラー処理有)
生成文字列の標準出力への出力
文字列用メモリの解放
・テストコードを別途生成
テスト対象関数の宣言
main()を伴うテストコード
文字列生成関数を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
sample_code.c: In function ‘generate_range_string’:
sample_code.c:35:13: warning: unused variable ‘len’ [-Wunused-variable]
35 | int len = snprintf(temp, sizeof(temp), "%d", i);
| ^~~
$ gcc -Wall -o sample_test sample_code.c sample_test.c
sample_code.c: In function ‘generate_range_string’:
sample_code.c:35:13: warning: unused variable ‘len’ [-Wunused-variable]
35 | int len = snprintf(temp, sizeof(temp), "%d", i);
| ^~~
/bin/ld: /tmp/ccfI6Dlq.o: in function `main':
sample_test.c:(.text+0xcd): multiple definition of `main'; /tmp/cc1pYgWd.o:sample_code.c:(.text+0x14f): 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.c: In function ‘generate_range_string’:
sample_code.c:35:13: warning: unused variable ‘len’ [-Wunused-variable]
35 | int len = snprintf(temp, sizeof(temp), "%d", i);
| ^~~
$ ./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
[PASS] Normal range
[PASS] Single element range
[PASS] Start greater than end
[PASS] Range including negative numbers
Result: 4/4 tests passed
(2) temperature=0.70; top_p=0.7; top_k=--
2026-07-29
total duration: 16m55.592190033s
load duration: 3.448842818s
prompt eval count: 205 token(s)
prompt eval duration: 1.133454593s
prompt eval rate: 180.86 tokens/s
eval count: 3303 token(s)
eval duration: 16m49.321330355s
eval rate: 3.27 tokens/s
コード生成結果の概要
・C言語による生成
・コード以外の出力無し
・コードの記述スタイルをオールマンで生成
・戻り値は stdlib.h の EXIT_*** を使用
・文字列生成関数
引数値のチェック(エラー判定有)
文字列長に応じたメモリの確保(エラー処理有)
インクリメント+空白区切りで文字列用メモリに書き込み
文字列用メモリへのポインタを返す
・main()
引数個数のチェック(エラー処理有)
文字列生成関数の呼び出し
生成文字列の標準出力への出力
文字列用メモリの解放
・テストコードを別途生成
テスト対象関数の宣言
main()を伴うテストコード
文字列生成関数を4種類の引数の組み合わせでテスト実行
(1) 整数1 < 整数2
(2) 整数1 < 整数2 ただし、整数1、整数2が共に2桁
(3) 整数1 == 整数2
(4) 整数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
/bin/ld: /tmp/cc6yJoyt.o: in function `main':
sample_test.c:(.text+0xdb): multiple definition of `main'; /tmp/cckDqizC.o:sample_code.c:(.text+0xec): 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 Results: 4/4 passed
(3) temperature=0.50; top_p=0.7; top_k=--
2026-07-29
total duration: 17m25.44260639s
load duration: 157.732571ms
prompt eval count: 205 token(s)
prompt eval duration: 286.391544ms
prompt eval rate: 715.80 tokens/s
eval count: 3397 token(s)
eval duration: 17m23.365284143s
eval rate: 3.26 tokens/s
コード生成結果の概要
・C言語による生成
・コード以外の出力無し
・コードの記述スタイルをオールマンで生成
・戻り値は stdlib.h の EXIT_*** を使用
・文字列生成関数
引数値のチェック(エラー判定有)
文字列長に応じたメモリの確保(エラー処理有)
インクリメント+空白区切りで文字列用メモリに書き込み
文字列用メモリへのポインタを返す
・main()
引数個数のチェック(エラー処理有)
文字列生成関数の呼び出し
生成文字列の標準出力への出力
文字列用メモリの解放
・テストコードを別途生成
テスト対象関数の宣言
main()を伴うテストコード
文字列生成関数を5種類の引数の組み合わせでテスト実行
(1) 整数1 < 整数2
(2) 整数1 < 整数2 ただし、整数1、整数2が共に2桁
(3) 整数1 == 整数2 ただし、整数1と整数2は共に0
(4) 整数1 < 整数2 ただし、整数1が負数
(5) 整数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
/bin/ld: /tmp/ccRjJ4dZ.o: in function `main':
sample_test.c:(.text+0x0): multiple definition of `main'; /tmp/ccTwervW.o:sample_code.c:(.text+0xfb): 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
All tests passed.
(4) temperature=0.30; top_p=0.7; top_k=--
2026-07-29
total duration: 34m51.266050841s
load duration: 153.416789ms
prompt eval count: 205 token(s)
prompt eval duration: 292.1533ms
prompt eval rate: 701.69 tokens/s
eval count: 6671 token(s)
eval duration: 34m47.376249931s
eval rate: 3.20 tokens/s
コード生成結果の概要
・C言語による生成
・コード以外の出力無し
・コードの記述スタイルのオールマン指定を無視
・戻り値は stdlib.h の EXIT_*** を使用
・文字列生成関数
引数値のチェック(エラー判定有)
文字列長に応じたメモリの確保(エラー処理有)
インクリメント+空白区切りで文字列用メモリに書き込み
文字列用メモリへのポインタを返す
・main()
引数個数のチェック(エラー処理有)
文字列生成関数の呼び出し
生成文字列の標準出力への出力
文字列用メモリの解放
・テストコードを別途生成
実行用コードと同一の文字列生成関数定義を記述
本番環境用と称するコードが混在しているため、修正無しでは実行不可能
main()を伴うテストコード
文字列生成関数を5種類の引数の組み合わせでテスト実行
(1) 整数1 < 整数2
(2) 整数1 == 整数2
(3) 整数1 < 整数2 ただし、整数1が負数
(4) 整数1 < 整数2 ただし、整数1、整数2は共に負数
(5) 整数1 > 整数2
(注) LLMの生成結果は毎回一定ではないため、結果によっては上記内容通りではないことが考えられます。
生成コードの実行結果
sample_code.c : 検証用プロンプトにて生成されたコードsample_test.c : 生成されたテストコード
$ gcc -Wall -o sample_code sample_code.c
$ gcc -Wall -o sample_test sample_test.c
sample_test.c:69:7: error: redefinition of ‘build_range_string’
69 | char* build_range_string(int s, int e) {
| ^~~~~~~~~~~~~~~~~~
sample_test.c:10:7: note: previous definition of ‘build_range_string’ with type ‘char *(int, int)’
10 | char* build_range_string(int start, int end) {
| ^~~~~~~~~~~~~~~~~~
sample_test.c: In function ‘build_range_string’:
sample_test.c:70:12: warning: implicit declaration of function ‘build_range_string_impl’; did you mean ‘build_range_string’? [-Wimplicit-function-declaration]
70 | return build_range_string_impl(s, e);
| ^~~~~~~~~~~~~~~~~~~~~~~
| build_range_string
sample_test.c:70:12: warning: returning ‘int’ from a function with return type ‘char *’ makes pointer from integer without a cast [-Wint-conversion]
70 | return build_range_string_impl(s, e);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
sample_test.c: At top level:
sample_test.c:74:7: error: conflicting types for ‘build_range_string_impl’; have ‘char *(int, int)’
74 | char* build_range_string_impl(int s, int e) {
| ^~~~~~~~~~~~~~~~~~~~~~~
sample_test.c:70:12: note: previous implicit declaration of ‘build_range_string_impl’ with type ‘int()’
70 | return build_range_string_impl(s, e);
| ^~~~~~~~~~~~~~~~~~~~~~~
sample_test.c: In function ‘build_range_string_impl’:
sample_test.c:77:12: warning: implicit declaration of function ‘build_range_string_logic’; did you mean ‘build_range_string_impl’? [-Wimplicit-function-declaration]
77 | return build_range_string_logic(s, e);
| ^~~~~~~~~~~~~~~~~~~~~~~~
| build_range_string_impl
sample_test.c:77:12: warning: returning ‘int’ from a function with return type ‘char *’ makes pointer from integer without a cast [-Wint-conversion]
77 | return build_range_string_logic(s, e);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
sample_test.c: At top level:
sample_test.c:81:7: error: conflicting types for ‘build_range_string_logic’; have ‘char *(int, int)’
81 | char* build_range_string_logic(int s, int e) {
| ^~~~~~~~~~~~~~~~~~~~~~~~
sample_test.c:77:12: note: previous implicit declaration of ‘build_range_string_logic’ with type ‘int()’
77 | return build_range_string_logic(s, e);
| ^~~~~~~~~~~~~~~~~~~~~~~~
$ vi sample_test.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
Error: Invalid range (start must be less than or equal to end).
$ ./sample_test
Running tests...
PASS: [1, 5] -> 1 2 3 4 5
PASS: [10, 10] -> 10
PASS: [-3, 1] -> -3 -2 -1 0 1
PASS: [-10, -8] -> -10 -9 -8
PASS: [5, 1] -> NULL
Tests completed.
(5) temperature=0.15; top_p=---; top_k=--
2026-07-29
total duration: 13m59.047409417s
load duration: 187.476113ms
prompt eval count: 205 token(s)
prompt eval duration: 1.183484861s
prompt eval rate: 173.22 tokens/s
eval count: 2745 token(s)
eval duration: 13m56.414633184s
eval rate: 3.28 tokens/s
コード生成結果の概要
・C言語による生成
・コード以外の出力無し
・コードの記述スタイルをオールマンで生成
・戻り値は stdlib.h の EXIT_*** を使用
・文字列生成関数
引数値のチェック(エラー判定有)
文字列長に応じたメモリの確保(エラー処理有)
インクリメント+空白区切りで文字列用メモリに書き込み
文字列用メモリへのポインタを返す
・main()
引数個数のチェック(エラー処理有)
文字列生成関数の呼び出し(エラー処理有)
生成文字列の標準出力への出力
文字列用メモリの解放
・テストコードを別途生成
テスト対象関数の宣言
main()を伴うテストコード
文字列生成関数を4種類の引数の組み合わせでテスト実行
(1) 整数1 < 整数2
(2) 整数1 < 整数2 ただし、整数1、整数2は共に2桁
(3) 整数1 == 整数2
(4) 整数1 > 整数2
(注) LLMの生成結果は毎回一定ではないため、結果によっては上記内容通りではないことが考えられます。
生成コードの実行結果
sample_code.c : 検証用プロンプトにて生成されたコードsample_test.c : 生成されたテストコード
$ gcc -Wall -o sample_code sample_code.c
sample_code.c: In function ‘generate_range_string’:
sample_code.c:28:9: warning: implicit declaration of function ‘strcat’ [-Wimplicit-function-declaration]
28 | strcat(result, temp);
| ^~~~~~
sample_code.c:3:1: note: include ‘<string.h>’ or provide a declaration of ‘strcat’
2 | #include <stdlib.h>
+++ |+#include <string.h>
3 |
sample_code.c:28:9: warning: incompatible implicit declaration of built-in function ‘strcat’ [-Wbuiltin-declaration-mismatch]
28 | strcat(result, temp);
| ^~~~~~
sample_code.c:28:9: note: include ‘<string.h>’ or provide a declaration of ‘strcat’
sample_code.c:27:13: warning: unused variable ‘len’ [-Wunused-variable]
27 | int len = snprintf(temp, sizeof(temp), "%d%s", i, (i == end) ? "" : " ");
| ^~~
$ gcc -Wall -o sample_test sample_code.c sample_test.c
sample_code.c: In function ‘generate_range_string’:
sample_code.c:28:9: warning: implicit declaration of function ‘strcat’ [-Wimplicit-function-declaration]
28 | strcat(result, temp);
| ^~~~~~
sample_code.c:3:1: note: include ‘<string.h>’ or provide a declaration of ‘strcat’
2 | #include <stdlib.h>
+++ |+#include <string.h>
3 |
sample_code.c:28:9: warning: incompatible implicit declaration of built-in function ‘strcat’ [-Wbuiltin-declaration-mismatch]
28 | strcat(result, temp);
| ^~~~~~
sample_code.c:28:9: note: include ‘<string.h>’ or provide a declaration of ‘strcat’
sample_code.c:27:13: warning: unused variable ‘len’ [-Wunused-variable]
27 | int len = snprintf(temp, sizeof(temp), "%d%s", i, (i == end) ? "" : " ");
| ^~~
/bin/ld: /tmp/ccIvf5YC.o: in function `main':
sample_test.c:(.text+0x102): multiple definition of `main'; /tmp/ccsxCWx3.o:sample_code.c:(.text+0x121): 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.c: In function ‘generate_range_string’:
sample_code.c:28:9: warning: implicit declaration of function ‘strcat’ [-Wimplicit-function-declaration]
28 | strcat(result, temp);
| ^~~~~~
sample_code.c:3:1: note: include ‘<string.h>’ or provide a declaration of ‘strcat’
2 | #include <stdlib.h>
+++ |+#include <string.h>
3 |
sample_code.c:28:9: warning: incompatible implicit declaration of built-in function ‘strcat’ [-Wbuiltin-declaration-mismatch]
28 | strcat(result, temp);
| ^~~~~~
sample_code.c:28:9: note: include ‘<string.h>’ or provide a declaration of ‘strcat’
sample_code.c:27:13: warning: unused variable ‘len’ [-Wunused-variable]
27 | int len = snprintf(temp, sizeof(temp), "%d%s", i, (i == end) ? "" : " ");
| ^~~
$ ./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
Error: Start value must be less than or equal to end value.
$ ./sample_test
Test 1: PASSED
Test 2: PASSED
Test 3: PASSED
Test 4: PASSED
Result: 4/4 tests passed.
(6) temperature=0.15; top_p=0.7; top_k=--
2026-07-29
total duration: -
load duration: -
prompt eval count: -
prompt eval duration: -
prompt eval rate: -
eval count: -
eval duration: -
eval rate: -
コード生成結果の概要
無限ループ発生
生成コードの実行結果
Thinking...
︙
* *Wait*, I'll provide the implementation and the test.
* *Actually*, I'll just provide the implementation.
* *Wait*, I'll provide the implementation and the test.
* *Actually*, I'll just provide the implementation^C
(7) temperature=0.15; top_p=0.7; top_k=--
2026-07-29
total duration: 14m19.558691203s
load duration: 3.505037108s
prompt eval count: 205 token(s)
prompt eval duration: 1.174359825s
prompt eval rate: 174.56 tokens/s
eval count: 2825 token(s)
eval duration: 14m13.397857071s
eval rate: 3.31 tokens/s
コード生成結果の概要
・C言語による生成
・コード以外の出力無し
・コードの記述スタイルをオールマンで生成
・戻り値は stdlib.h の EXIT_*** を使用
・文字列生成関数
引数値のチェック(エラー判定有)
文字列長に応じたメモリの確保(エラー処理有)
インクリメント+空白区切りで文字列用メモリに書き込み
文字列用メモリへのポインタを返す
・main()
引数個数のチェック(エラー処理有)
文字列生成関数の呼び出し(エラー処理有)
生成文字列の標準出力への出力
文字列用メモリの解放
・テストコードを別途生成
テスト対象関数の宣言
main()を伴うテストコード
文字列生成関数を5種類の引数の組み合わせでテスト実行
(1) 整数1 < 整数2
(2) 整数1 < 整数2 ただし、整数1、整数2が共に2桁
(3) 整数1 == 整数2
(4) 整数1 > 整数2
(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_string’:
sample_code.c:30:9: warning: implicit declaration of function ‘strcat’ [-Wimplicit-function-declaration]
30 | strcat(result, temp);
| ^~~~~~
sample_code.c:3:1: note: include ‘<string.h>’ or provide a declaration of ‘strcat’
2 | #include <stdlib.h>
+++ |+#include <string.h>
3 |
sample_code.c:30:9: warning: incompatible implicit declaration of built-in function ‘strcat’ [-Wbuiltin-declaration-mismatch]
30 | strcat(result, temp);
| ^~~~~~
sample_code.c:30:9: note: include ‘<string.h>’ or provide a declaration of ‘strcat’
sample_code.c:29:13: warning: unused variable ‘len’ [-Wunused-variable]
29 | int len = snprintf(temp, sizeof(temp), "%d%s", i, (i == end) ? "" : " ");
| ^~~
sample_code.c:11:9: warning: unused variable ‘count’ [-Wunused-variable]
11 | int count = end - start + 1;
| ^~~~~
$ gcc -Wall -o sample_test sample_code.c sample_test.c
sample_code.c: In function ‘generate_range_string’:
sample_code.c:30:9: warning: implicit declaration of function ‘strcat’ [-Wimplicit-function-declaration]
30 | strcat(result, temp);
| ^~~~~~
sample_code.c:3:1: note: include ‘<string.h>’ or provide a declaration of ‘strcat’
2 | #include <stdlib.h>
+++ |+#include <string.h>
3 |
sample_code.c:30:9: warning: incompatible implicit declaration of built-in function ‘strcat’ [-Wbuiltin-declaration-mismatch]
30 | strcat(result, temp);
| ^~~~~~
sample_code.c:30:9: note: include ‘<string.h>’ or provide a declaration of ‘strcat’
sample_code.c:29:13: warning: unused variable ‘len’ [-Wunused-variable]
29 | int len = snprintf(temp, sizeof(temp), "%d%s", i, (i == end) ? "" : " ");
| ^~~
sample_code.c:11:9: warning: unused variable ‘count’ [-Wunused-variable]
11 | int count = end - start + 1;
| ^~~~~
/bin/ld: /tmp/ccWq5P22.o: in function `main':
sample_test.c:(.text+0xdb): multiple definition of `main'; /tmp/ccEZl6Zv.o:sample_code.c:(.text+0x129): 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.c: In function ‘generate_range_string’:
sample_code.c:30:9: warning: implicit declaration of function ‘strcat’ [-Wimplicit-function-declaration]
30 | strcat(result, temp);
| ^~~~~~
sample_code.c:3:1: note: include ‘<string.h>’ or provide a declaration of ‘strcat’
2 | #include <stdlib.h>
+++ |+#include <string.h>
3 |
sample_code.c:30:9: warning: incompatible implicit declaration of built-in function ‘strcat’ [-Wbuiltin-declaration-mismatch]
30 | strcat(result, temp);
| ^~~~~~
sample_code.c:30:9: note: include ‘<string.h>’ or provide a declaration of ‘strcat’
sample_code.c:29:13: warning: unused variable ‘len’ [-Wunused-variable]
29 | int len = snprintf(temp, sizeof(temp), "%d%s", i, (i == end) ? "" : " ");
| ^~~
sample_code.c:11:9: warning: unused variable ‘count’ [-Wunused-variable]
11 | int count = end - start + 1;
| ^~~~~
$ ./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 Results: 5/5 passed
(8) temperature=0.15; top_p=0.5; top_k=--
2026-07-29
total duration: 14m23.778505384s
load duration: 3.511348053s
prompt eval count: 205 token(s)
prompt eval duration: 1.154952002s
prompt eval rate: 177.50 tokens/s
eval count: 2839 token(s)
eval duration: 14m17.629190412s
eval rate: 3.31 tokens/s
コード生成結果の概要
・C言語による生成
・コード以外の出力無し
・コードの記述スタイルをオールマンで生成
・戻り値は stdlib.h の EXIT_*** を使用
・文字列生成関数
引数値のチェック(エラー判定有)
文字列長に応じたメモリの確保(エラー処理有)
インクリメント+空白区切りで文字列用メモリに書き込み
文字列用メモリへのポインタを返す
・main()
引数個数のチェック(エラー処理有)
文字列生成関数の呼び出し(エラー処理有)
生成文字列の標準出力への出力
文字列用メモリの解放
・テストコードを別途生成
テスト対象関数の宣言
main()を伴うテストコード
文字列生成関数を5種類の引数の組み合わせでテスト実行
(1) 整数1 < 整数2
(2) 整数1 < 整数2 ただし、整数1、整数2が共に2桁
(3) 整数1 == 整数2 ただし、整数1と整数2は共に0
(4) 整数1 < 整数2 ただし、整数1が負数
(5) 整数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
/bin/ld: /tmp/ccuHQAVJ.o: in function `main':
sample_test.c:(.text+0x8a): multiple definition of `main'; /tmp/ccqKMv7a.o:sample_code.c:(.text+0xf1): 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
Error: Start value must be less than or equal to end value.
$ ./sample_test
Test 1: PASSED
Test 2: PASSED
Test 3: PASSED
Test 4: PASSED
Test 5: PASSED
Result: 5/5 passed
(9) temperature=0.15; top_p=0.4; top_k=--
2026-07-29
total duration: 26m2.593189889s
load duration: 3.506953667s
prompt eval count: 205 token(s)
prompt eval duration: 1.173416471s
prompt eval rate: 174.70 tokens/s
eval count: 4992 token(s)
eval duration: 25m55.247892574s
eval rate: 3.21 tokens/s
コード生成結果の概要
・C言語による生成
・thinking終了後、修正版コードの再出力有り
・コードの記述スタイルをオールマンで生成
・stdlib.h の EXIT_*** の使用指示を無視
・文字列生成関数
引数値のチェック(エラー判定有)
文字列長に応じたメモリの確保(エラー処理有)
インクリメント+空白区切りで文字列用メモリに書き込み
文字列用メモリへのポインタを返す
・main()
引数個数のチェック(エラー処理有)
文字列生成関数の呼び出し(エラー処理有)
生成文字列の標準出力への出力
文字列用メモリの解放
・テストコードを別途生成
テスト対象関数の宣言
main()を伴うテストコード
文字列生成関数を4種類の引数の組み合わせでテスト実行
(1) 整数1 < 整数2
(2) 整数1 < 整数2 ただし、整数1、整数2が共に2桁
(3) 整数1 == 整数2
(4) 整数1 > 整数2
テスト時のmain()の重複に関する注意を促す記述有り
(注) 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/ccAFyCHD.o: in function `main':
sample_test.c:(.text+0x0): multiple definition of `main'; /tmp/cc1og3RW.o:sample_code.c:(.text+0x10b): 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: PASSED
Test 2: PASSED
Test 3: PASSED
Test 4: PASSED
All tests passed!
(10) temperature=0.15; top_p=0.7; top_k=32
2026-07-29
total duration: -
load duration: -
prompt eval count: -
prompt eval duration: -
prompt eval rate: -
eval count: -
eval duration: -
eval rate: -
コード生成結果の概要
無限ループ発生
(11) temperature=0.15; top_p=0.7; top_k=32
2026-07-29
total duration: 26m25.584050941s
load duration: 174.132794ms
prompt eval count: 205 token(s)
prompt eval duration: 1.170163632s
prompt eval rate: 175.19 tokens/s
eval count: 5043 token(s)
eval duration: 26m21.8124492s
eval rate: 3.19 tokens/s
コード生成結果の概要
・C言語による生成
・thinking終了後、修正版コードの再出力有り
・コードの記述スタイルをオールマンで生成
・戻り値は stdlib.h の EXIT_*** を使用
テストコードは stdlib.h の EXIT_*** の使用指示を無視
・文字列生成関数
start > end の場合はNULL文字のみのメモリへのポインタを返す
文字列長に応じたメモリの確保(エラー処理有)
インクリメント+空白区切りで文字列用メモリに書き込み
文字列用メモリへのポインタを返す
・main()
引数個数のチェック(エラー処理有)
文字列生成関数の呼び出し(エラー処理有)
生成文字列の標準出力への出力
文字列用メモリの解放
・テストコードを別途生成
テスト対象関数の宣言
main()を伴うテストコード
文字列生成関数を4種類の引数の組み合わせでテスト実行
(1) 整数1 < 整数2
(2) 整数1 < 整数2 ただし、整数1が負数
(3) 整数1 == 整数2
(4) 整数1 > 整数2
コードが不足しコンパイル不能
(注) LLMの生成結果は毎回一定ではないため、結果によっては上記内容通りではないことが考えられます。
生成コードの実行結果
sample_code.c : 検証用プロンプトにて生成されたコードsample_test.c : 生成されたテストコード
$ gcc -Wall -o sample_code sample_code.c
$ gcc -o sample_test sample_code.c sample_test.c
sample_test.c: In function ‘main’:
sample_test.c:46:16: warning: implicit declaration of function ‘run_test_empty’ [-Wimplicit-function-declaration]
46 | passed += (run_test_empty(10, 5) ? 1 : 0); // This is a conceptual check for the empty case
| ^~~~~~~~~~~~~~
sample_test.c:49:17: warning: implicit declaration of function ‘generate_sequence_test’; did you mean ‘generate_sequence’? [-Wimplicit-function-declaration]
49 | char *res = generate_sequence_test(10, 5); // Helper logic
| ^~~~~~~~~~~~~~~~~~~~~~
| generate_sequence
sample_test.c:49:17: warning: initialization of ‘char *’ from ‘int’ makes pointer from integer without a cast [-Wint-conversion]
/bin/ld: /tmp/ccgoM503.o: in function `main':
sample_test.c:(.text+0xbb): multiple definition of `main'; /tmp/ccNMcWft.o:sample_code.c:(.text+0xef): first defined here
/bin/ld: /tmp/ccgoM503.o: in function `main':
sample_test.c:(.text+0x145): undefined reference to `run_test_empty'
/bin/ld: sample_test.c:(.text+0x164): undefined reference to `generate_sequence_test'
collect2: error: ld returned 1 exit status ← 未定義の関数が2つありコンパイル不能
$ ./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
(12) temperature=0.15; top_p=0.7; top_k=16
2026-07-29
total duration: 15m29.19969264s
load duration: 167.501328ms
prompt eval count: 205 token(s)
prompt eval duration: 1.183069802s
prompt eval rate: 173.28 tokens/s
eval count: 3041 token(s)
eval duration: 15m26.634748934s
eval rate: 3.28 tokens/s
コード生成結果の概要
・C言語による生成
・thinking終了後、修正版コードの再出力有り
・コードの記述スタイルをオールマンで生成
・戻り値は stdlib.h の EXIT_*** を使用
・文字列生成関数
start > end の場合はNULL文字のみのメモリへのポインタを返す
文字列長に応じたメモリの確保(エラー処理有)
インクリメント+空白区切りで文字列用メモリに書き込み
文字列用メモリへのポインタを返す
・main()
引数個数のチェック(エラー処理有)
文字列生成関数の呼び出し(エラー処理有)
生成文字列の標準出力への出力
文字列用メモリの解放
テスト時重複対策のマクロ有り
・テストコードを別途生成
テスト対象関数の宣言
main()を伴うテストコード
文字列生成関数を4種類の引数の組み合わせでテスト実行
(1) 整数1 < 整数2
(2) 整数1 < 整数2 ただし、整数1が負数
(3) 整数1 == 整数2
(4) 整数1 > 整数2
(注) LLMの生成結果は毎回一定ではないため、結果によっては上記内容通りではないことが考えられます。
生成コードの実行結果
sample_code.c : 検証用プロンプトにて生成されたコードsample_test.c : 生成されたテストコード
$ gcc -Wall -o sample_code sample_code.c
sample_code.c: In function ‘generate_range_string’:
sample_code.c:35:22: warning: implicit declaration of function ‘strlen’ [-Wimplicit-function-declaration]
35 | (int)strlen(buffer)
| ^~~~~~
sample_code.c:3:1: note: include ‘<string.h>’ or provide a declaration of ‘strlen’
2 | #include <stdlib.h>
+++ |+#include <string.h>
3 |
sample_code.c:35:22: warning: incompatible implicit declaration of built-in function ‘strlen’ [-Wbuiltin-declaration-mismatch]
35 | (int)strlen(buffer)
| ^~~~~~
sample_code.c:35:22: note: include ‘<string.h>’ or provide a declaration of ‘strlen’
$ gcc -D TEST_MODE -Wall -o sample_test sample_code.c sample_test.c
sample_code.c: In function ‘generate_range_string’:
sample_code.c:35:22: warning: implicit declaration of function ‘strlen’ [-Wimplicit-function-declaration]
35 | (int)strlen(buffer)
| ^~~~~~
sample_code.c:3:1: note: include ‘<string.h>’ or provide a declaration of ‘strlen’
2 | #include <stdlib.h>
+++ |+#include <string.h>
3 |
sample_code.c:35:22: warning: incompatible implicit declaration of built-in function ‘strlen’ [-Wbuiltin-declaration-mismatch]
35 | (int)strlen(buffer)
| ^~~~~~
sample_code.c:35:22: note: include ‘<string.h>’ or provide a declaration of ‘strlen’
$ ./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: [1, 5] -> "1 2 3 4 5"
Test Passed: [-2, 2] -> "-2 -1 0 1 2"
Test Passed: [10, 10] -> "10"
Test Passed: [5, 1] -> ""
Result: 4/4 tests passed.
(13) temperature=0.10; top_p=0.7; top_k=--
2026-07-29
total duration: 31m4.826537167s
load duration: 160.987953ms
prompt eval count: 205 token(s)
prompt eval duration: 291.256903ms
prompt eval rate: 703.85 tokens/s
eval count: 5898 token(s)
eval duration: 31m1.365005579s
eval rate: 3.17 tokens/s
コード生成結果の概要
・C言語による生成
・コード以外の出力無し
・コードの記述スタイルのオールマン指定を無視
・stdlib.h の EXIT_*** の使用指示を無視
・文字列生成関数
s引数値のチェック(エラー判定有)
文字列長に応じたメモリの確保(エラー処理有)
インクリメント+空白区切りで文字列用メモリに書き込み
文字列用メモリへのポインタを返す
・main()
引数個数のチェック(エラー処理有)
文字列生成関数の呼び出し(エラー処理有)
生成文字列の標準出力への出力
文字列用メモリの解放
・テストコードを別途生成
実行用コードと同一の文字列生成関数定義を記述
main()を伴うテストコード
文字列生成関数を5種類の引数の組み合わせでテスト実行
(1) 整数1 < 整数2
(2) 整数1 < 整数2 ただし、整数1、整数2は共に2桁
(3) 整数1 == 整数2
(4) 整数1 > 整数2
(5) 整数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
Invalid range or memory error.
$ ./sample_test
Running tests...
PASS: Range [1, 5] -> "1 2 3 4 5"
PASS: Range [10, 12] -> "10 11 12"
PASS: Range [5, 5] -> "5"
PASS: Range [5, 4] is NULL
PASS: Range [-2, 1] -> "-2 -1 0 1"
Tests completed.